summaryrefslogtreecommitdiff
path: root/libutils/tests/Unicode_test.cpp
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2016-05-09 14:43:31 +0100
committerMichael Wright <michaelwr@google.com>2016-05-09 19:45:07 +0100
commit5bacef33c91e9625dfd09ecf638c2de7faecd34e (patch)
tree545ac749f183ec37edc89eb5e2066427cc0457fa /libutils/tests/Unicode_test.cpp
parentea41a18c933d20264b89fc89febf387231dc0c24 (diff)
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
Diffstat (limited to 'libutils/tests/Unicode_test.cpp')
-rw-r--r--libutils/tests/Unicode_test.cpp35
1 files changed, 35 insertions, 0 deletions
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);
+}
+
}