Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: test/cctest/test-strings.cc

Issue 11880045: Cleanup latin-1 conversion check in regexp engine (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/unicode-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-strings.cc
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index 0d2971b5ba31e09a7f75fd3af630e0479eea40ea..ea06b90a1880a0f3ab760279185a79be570262a2 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -1275,3 +1275,40 @@ TEST(IsAscii) {
CHECK(String::IsAscii(static_cast<char*>(NULL), 0));
CHECK(String::IsOneByte(static_cast<uc16*>(NULL), 0));
}
+
+
+static bool CanBeConvertedToLatin1(uint16_t c) {
+ CHECK(c > unibrow::Latin1::kMaxChar);
+ uint32_t result[4];
+ int chars;
+ chars = unibrow::ToLowercase::Convert(c, 0, result, NULL);
+ if (chars > 0) {
+ CHECK_LE(chars, static_cast<int>(sizeof(result)));
+ for (int i = 0; i < chars; i++ ) {
+ if (result[i] <= unibrow::Latin1::kMaxChar) {
+ return true;
+ }
+ }
+ }
+ chars = unibrow::ToUppercase::Convert(c, 0, result, NULL);
+ if (chars > 0) {
+ CHECK_LE(chars, static_cast<int>(sizeof(result)));
+ for (int i = 0; i < chars; i++ ) {
+ if (result[i] <= unibrow::Latin1::kMaxChar) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+
+TEST(Latin1) {
+#ifndef ENABLE_LATIN_1
+ if (true) return;
+#endif
+ for (uint16_t c = unibrow::Latin1::kMaxChar + 1; c != 0; c++) {
+ CHECK_EQ(CanBeConvertedToLatin1(c),
+ unibrow::Latin1::NonLatin1CanBeConvertedToLatin1(c));
+ }
+}
« no previous file with comments | « src/unicode-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698