summaryrefslogtreecommitdiffstats
path: root/runtime/utils_test.cc
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2015-05-06 14:55:43 +0100
committerNarayan Kamath <narayan@google.com>2015-05-07 11:22:36 +0100
commit3ba8671d60061359fd833f60f7a9dca14878cc0b (patch)
tree47cc0f1c2aeb9bb9c4a5878297c075fbcbe3fd38 /runtime/utils_test.cc
parent5c8fe3028655b2f1fcab77080272f071cc0d8bc4 (diff)
downloadart-3ba8671d60061359fd833f60f7a9dca14878cc0b.tar.gz
art-3ba8671d60061359fd833f60f7a9dca14878cc0b.tar.bz2
art-3ba8671d60061359fd833f60f7a9dca14878cc0b.zip
Fix broken checks in IsValidPartOfMemberNameUtf8Slow.
GetUtf16FromUtf8 returns a surrogate pair only if it encounters a 4-byte UTF sequence. Three byte UTF sequences will only return the first or second half of a pair so we need to check for that explicitly. bug: 20844537 Change-Id: Icb660fae77ac8a852fc768e6c1cd5766117e68e4
Diffstat (limited to 'runtime/utils_test.cc')
-rw-r--r--runtime/utils_test.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc
index 195de0c121..869d305120 100644
--- a/runtime/utils_test.cc
+++ b/runtime/utils_test.cc
@@ -521,4 +521,27 @@ TEST_F(UtilsTest, TestSleep) {
EXPECT_GT(NanoTime() - start, MsToNs(1000));
}
+TEST_F(UtilsTest, IsValidDescriptor) {
+ std::vector<uint8_t> descriptor(
+ { 'L', 'a', '/', 'b', '$', 0xed, 0xa0, 0x80, 0xed, 0xb0, 0x80, ';', 0x00 });
+ EXPECT_TRUE(IsValidDescriptor(reinterpret_cast<char*>(&descriptor[0])));
+
+ std::vector<uint8_t> unpaired_surrogate(
+ { 'L', 'a', '/', 'b', '$', 0xed, 0xa0, 0x80, ';', 0x00 });
+ EXPECT_FALSE(IsValidDescriptor(reinterpret_cast<char*>(&unpaired_surrogate[0])));
+
+ std::vector<uint8_t> unpaired_surrogate_at_end(
+ { 'L', 'a', '/', 'b', '$', 0xed, 0xa0, 0x80, 0x00 });
+ EXPECT_FALSE(IsValidDescriptor(reinterpret_cast<char*>(&unpaired_surrogate_at_end[0])));
+
+ std::vector<uint8_t> invalid_surrogate(
+ { 'L', 'a', '/', 'b', '$', 0xed, 0xb0, 0x80, ';', 0x00 });
+ EXPECT_FALSE(IsValidDescriptor(reinterpret_cast<char*>(&invalid_surrogate[0])));
+
+ std::vector<uint8_t> unpaired_surrogate_with_multibyte_sequence(
+ { 'L', 'a', '/', 'b', '$', 0xed, 0xb0, 0x80, 0xf0, 0x9f, 0x8f, 0xa0, ';', 0x00 });
+ EXPECT_FALSE(
+ IsValidDescriptor(reinterpret_cast<char*>(&unpaired_surrogate_with_multibyte_sequence[0])));
+}
+
} // namespace art