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

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

Issue 7706002: Slight API change enabling opting out from null termination in String::Write*(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 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
« include/v8.h ('K') | « 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-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index e206bb9ac366f3ed1ade216406cf9914410b6ca0..cd3e0873032173392c77122a95282fe08380de6e 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -5296,6 +5296,40 @@ THREADED_TEST(StringWrite) {
CHECK_EQ(0, strncmp("d\1", buf, 2));
uint16_t answer7[] = {'d', 0x101};
CHECK_EQ(0, StrNCmp16(answer7, wbuf, 2));
+
+ memset(wbuf, 0x1, sizeof(wbuf));
+ wbuf[5] = 'X';
+ len = str->Write(wbuf, 0, 6, String::WRITE_NO_NULL_TERMINATION);
+ CHECK_EQ(5, len);
+ CHECK_EQ('X', wbuf[5]);
+ uint16_t answer8a[] = {'a', 'b', 'c', 'd', 'e'};
+ uint16_t answer8b[] = {'a', 'b', 'c', 'd', 'e', '\0'};
+ CHECK_EQ(0, StrNCmp16(answer8a, wbuf, 5));
+ CHECK_NE(0, StrCmp16(answer8b, wbuf));
+ wbuf[5] = '\0';
+ CHECK_EQ(0, StrCmp16(answer8b, wbuf));
+
+ memset(buf, 0x1, sizeof(buf));
+ buf[5] = 'X';
+ len = str->WriteAscii(buf, 0, 6, String::WRITE_NO_NULL_TERMINATION);
+ CHECK_EQ(5, len);
+ CHECK_EQ('X', buf[5]);
+ CHECK_EQ(0, strncmp("abcde", buf, 5));
+ CHECK_NE(0, strcmp("abcde", buf));
+ buf[5] = '\0';
+ CHECK_EQ(0, strcmp("abcde", buf));
+
+ memset(utf8buf, 0x1, sizeof(utf8buf));
+ utf8buf[8] = 'X';
+ len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen,
+ String::WRITE_NO_NULL_TERMINATION);
+ CHECK_EQ(8, len);
+ CHECK_EQ('X', utf8buf[8]);
+ CHECK_EQ(5, charlen);
+ CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\342\230\203", 8));
+ CHECK_NE(0, strcmp(utf8buf, "abc\303\260\342\230\203"));
+ utf8buf[8] = '\0';
+ CHECK_EQ(0, strcmp(utf8buf, "abc\303\260\342\230\203"));
}
« include/v8.h ('K') | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698