Loading libutils/String16_test.cpp +18 −8 Original line number Diff line number Diff line Loading @@ -58,6 +58,14 @@ TEST(String16Test, Copy) { EXPECT_STR16EQ(u"Verify me", another); } TEST(String16Test, CopyAssign) { String16 tmp("Verify me"); String16 another; another = tmp; EXPECT_STR16EQ(u"Verify me", tmp); EXPECT_STR16EQ(u"Verify me", another); } TEST(String16Test, Move) { String16 tmp("Verify me"); String16 another(std::move(tmp)); Loading Loading @@ -130,10 +138,6 @@ TEST(String16Test, StaticStringMove) { String16 another(std::move(tmp)); EXPECT_STR16EQ(u"Verify me", another); EXPECT_TRUE(another.isStaticString()); // move/copy from StaticString16 is specialized (just copy the handle). // no extra actions required. EXPECT_STR16EQ(u"Verify me", tmp); EXPECT_TRUE(tmp.isStaticString()); } TEST(String16Test, StaticStringSize) { Loading Loading @@ -185,18 +189,24 @@ TEST(String16Test, StringSetToStaticString) { EXPECT_STR16EQ(u"Verify me", another); } TEST(String16Test, StringMoveAssignFromStaticString) { TEST(String16Test, StringCopyAssignFromStaticString) { StaticString16 tmp(u"Verify me"); String16 another(u"nonstatic"); another = std::move(tmp); another = tmp; EXPECT_STR16EQ(u"Verify me", another); EXPECT_TRUE(another.isStaticString()); // move/copy from StaticString16 is specialized (just copy handle). // no extra actions required. EXPECT_STR16EQ(u"Verify me", tmp); EXPECT_TRUE(tmp.isStaticString()); } TEST(String16Test, StringMoveAssignFromStaticString) { StaticString16 tmp(u"Verify me"); String16 another(u"nonstatic"); another = std::move(tmp); EXPECT_STR16EQ(u"Verify me", another); EXPECT_TRUE(another.isStaticString()); } TEST(String16Test, EmptyStringIsStatic) { String16 tmp(""); EXPECT_TRUE(tmp.isStaticString()); Loading libutils/include/utils/String16.h +0 −10 Original line number Diff line number Diff line Loading @@ -174,16 +174,6 @@ protected: template <size_t N> explicit constexpr String16(const StaticData<N>& s) : mString(s.data) {} public: template <size_t N> explicit constexpr String16(const StaticString16<N>& s) : mString(s.mString) {} template <size_t N> constexpr String16& operator=(const StaticString16<N>& s) { release(); mString = s.mString; return *this; } }; // String16 can be trivially moved using memcpy() because moving does not Loading Loading
libutils/String16_test.cpp +18 −8 Original line number Diff line number Diff line Loading @@ -58,6 +58,14 @@ TEST(String16Test, Copy) { EXPECT_STR16EQ(u"Verify me", another); } TEST(String16Test, CopyAssign) { String16 tmp("Verify me"); String16 another; another = tmp; EXPECT_STR16EQ(u"Verify me", tmp); EXPECT_STR16EQ(u"Verify me", another); } TEST(String16Test, Move) { String16 tmp("Verify me"); String16 another(std::move(tmp)); Loading Loading @@ -130,10 +138,6 @@ TEST(String16Test, StaticStringMove) { String16 another(std::move(tmp)); EXPECT_STR16EQ(u"Verify me", another); EXPECT_TRUE(another.isStaticString()); // move/copy from StaticString16 is specialized (just copy the handle). // no extra actions required. EXPECT_STR16EQ(u"Verify me", tmp); EXPECT_TRUE(tmp.isStaticString()); } TEST(String16Test, StaticStringSize) { Loading Loading @@ -185,18 +189,24 @@ TEST(String16Test, StringSetToStaticString) { EXPECT_STR16EQ(u"Verify me", another); } TEST(String16Test, StringMoveAssignFromStaticString) { TEST(String16Test, StringCopyAssignFromStaticString) { StaticString16 tmp(u"Verify me"); String16 another(u"nonstatic"); another = std::move(tmp); another = tmp; EXPECT_STR16EQ(u"Verify me", another); EXPECT_TRUE(another.isStaticString()); // move/copy from StaticString16 is specialized (just copy handle). // no extra actions required. EXPECT_STR16EQ(u"Verify me", tmp); EXPECT_TRUE(tmp.isStaticString()); } TEST(String16Test, StringMoveAssignFromStaticString) { StaticString16 tmp(u"Verify me"); String16 another(u"nonstatic"); another = std::move(tmp); EXPECT_STR16EQ(u"Verify me", another); EXPECT_TRUE(another.isStaticString()); } TEST(String16Test, EmptyStringIsStatic) { String16 tmp(""); EXPECT_TRUE(tmp.isStaticString()); Loading
libutils/include/utils/String16.h +0 −10 Original line number Diff line number Diff line Loading @@ -174,16 +174,6 @@ protected: template <size_t N> explicit constexpr String16(const StaticData<N>& s) : mString(s.data) {} public: template <size_t N> explicit constexpr String16(const StaticString16<N>& s) : mString(s.mString) {} template <size_t N> constexpr String16& operator=(const StaticString16<N>& s) { release(); mString = s.mString; return *this; } }; // String16 can be trivially moved using memcpy() because moving does not Loading