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")); |
} |