From 5bacef33c91e9625dfd09ecf638c2de7faecd34e Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 9 May 2016 14:43:31 +0100 Subject: Add String16#contains and strstr16 methods. These are needed for aapt to find javadoc comments that contain "@removed" in order to skip them when printing styleable docs. Bug: 28663748 Change-Id: I8866d2167c41e11d6c2586da369560d5815fd13e --- libutils/tests/Unicode_test.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'libutils/tests/Unicode_test.cpp') diff --git a/libutils/tests/Unicode_test.cpp b/libutils/tests/Unicode_test.cpp index 18c130c55..c263f75e2 100644 --- a/libutils/tests/Unicode_test.cpp +++ b/libutils/tests/Unicode_test.cpp @@ -29,6 +29,8 @@ protected: virtual void TearDown() { } + + char16_t const * const kSearchString = u"I am a leaf on the wind."; }; TEST_F(UnicodeTest, UTF8toUTF16ZeroLength) { @@ -112,4 +114,37 @@ TEST_F(UnicodeTest, UTF8toUTF16Normal) { << "should be NULL terminated"; } +TEST_F(UnicodeTest, strstr16EmptyTarget) { + EXPECT_EQ(strstr16(kSearchString, u""), kSearchString) + << "should return the original pointer"; +} + +TEST_F(UnicodeTest, strstr16SameString) { + const char16_t* result = strstr16(kSearchString, kSearchString); + EXPECT_EQ(kSearchString, result) + << "should return the original pointer"; +} + +TEST_F(UnicodeTest, strstr16TargetStartOfString) { + const char16_t* result = strstr16(kSearchString, u"I am"); + EXPECT_EQ(kSearchString, result) + << "should return the original pointer"; +} + + +TEST_F(UnicodeTest, strstr16TargetEndOfString) { + const char16_t* result = strstr16(kSearchString, u"wind."); + EXPECT_EQ(kSearchString+19, result); +} + +TEST_F(UnicodeTest, strstr16TargetWithinString) { + const char16_t* result = strstr16(kSearchString, u"leaf"); + EXPECT_EQ(kSearchString+7, result); +} + +TEST_F(UnicodeTest, strstr16TargetNotPresent) { + const char16_t* result = strstr16(kSearchString, u"soar"); + EXPECT_EQ(nullptr, result); +} + } -- cgit v1.2.3