diff options
author | Julian Andres Klode <jak@debian.org> | 2016-08-18 10:02:35 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2016-08-18 10:02:35 +0200 |
commit | d1fd09b982f6108dc32ec75330b0535236c48311 (patch) | |
tree | c0dce6cf7501c1e0d5e3bad34e9b63c0d6dcd354 /test/libapt/stringview_test.cc | |
parent | b5fcba3682581b2a48921cc830dbf3deae6b0ff3 (diff) | |
parent | 43670e2ef8b689d9efba633d11d2a5fc6f9968a0 (diff) |
Merge tag '1.3_rc2' into ubuntu
apt Debian release 1.3~rc2
Diffstat (limited to 'test/libapt/stringview_test.cc')
-rw-r--r-- | test/libapt/stringview_test.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/test/libapt/stringview_test.cc b/test/libapt/stringview_test.cc index a4b7d77e3..f215287d9 100644 --- a/test/libapt/stringview_test.cc +++ b/test/libapt/stringview_test.cc @@ -34,26 +34,28 @@ TEST(StringViewTest,EmptyString) TEST(StringViewTest,FooString) { - constexpr APT::StringView defString("foo", 3); + constexpr APT::StringView defString("fooGARBAGE", 3); static_assert( 3 == defString.length(), "def right size"); - EXPECT_EQ(defString.to_string(), defString.data()); + EXPECT_EQ(0, defString.to_string().compare(0, defString.length(), defString.data(), 3)); APT::StringView strString{std::string{"foo"}}; EXPECT_EQ(3, strString.length()); - EXPECT_EQ(strString.to_string(), strString.data()); + EXPECT_EQ(0, strString.to_string().compare(0, strString.length(), strString.data(), 3)); - constexpr char const * const charp = "foo"; + constexpr char const * const charp = "fooGARBAGE"; constexpr APT::StringView charpString{charp, 3}; - EXPECT_EQ( 3, charpString.length()); - EXPECT_EQ(charpString.to_string(), charpString.data()); + EXPECT_EQ(3, charpString.length()); + EXPECT_EQ(0, charpString.to_string().compare(0, charpString.length(), charpString.data(), 3)); - APT::StringView charp2String{charp}; + char * charp2 = strdup("foo"); + APT::StringView charp2String{charp2}; EXPECT_EQ(3, charp2String.length()); - EXPECT_EQ(charp2String.to_string(), charp2String.data()); + EXPECT_EQ(0, charp2String.to_string().compare(0, charp2String.length(), charp2String.data(), 3)); + free(charp2); const APT::StringView charaString{"foo"}; EXPECT_EQ(3, charaString.length()); - EXPECT_EQ(charaString.to_string(), charaString.data()); + EXPECT_EQ(0, charaString.to_string().compare(0, charaString.length(), charaString.data(), 3)); EXPECT_TRUE(APT::StringView("foo") == "foo"); EXPECT_FALSE(APT::StringView("foo") != "foo"); |