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

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

Issue 1594017: Flatten before String::WriteUtf8 (Closed)
Patch Set: Add isDeadCheck and isFlat tests Created 10 years, 8 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/api.cc ('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 59a40af2a675c586df40e2f41dde5cf2955dfe27..d20a57764ef30145bfe4c501bdcb59b697931453 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -344,6 +344,38 @@ TEST(Utf8Conversion) {
}
+TEST(StringConcatFlatten) {
+ InitializeVM();
+ v8::HandleScope handle_scope;
+
+ const char* stringA = "0123456789";
+ const char* stringB = "ABCDEFGHIJ";
+
+ v8::Local<v8::String> a = v8::String::New(stringA);
+ v8::Local<v8::String> b = v8::String::New(stringB);
+
+ v8::Local<v8::String> cons = v8::String::Concat(a,b);
+
+ i::Handle<i::String> str = v8::Utils::OpenHandle(*cons);
+ CHECK_EQ(false, str->IsFlat());
antonm 2010/04/08 11:23:41 would you mind if I change that to CHECK(!str->IsF
+
+ cons->Flatten();
+
+ CHECK_EQ(true, str->IsFlat());
antonm 2010/04/08 11:23:41 would you mind if I change that to CHECK(str->IsFl
+
+ char buffer[21];
+ cons->WriteUtf8(buffer);
+
+ for (int j = 0; j < 10; j++) {
antonm 2010/04/08 11:23:41 why j, not i? :) I could change to i when landing
+ CHECK_EQ(stringA[j], buffer[j]);
+ }
+
+ for (int j = 0; j < 10; j++) {
+ CHECK_EQ(stringB[j], buffer[j+10]);
+ }
+}
+
+
TEST(ExternalShortStringAdd) {
ZoneScope zone(DELETE_ON_EXIT);
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698