summaryrefslogtreecommitdiffstats
path: root/xpcom/tests/gtest/TestStrings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xpcom/tests/gtest/TestStrings.cpp')
-rw-r--r--xpcom/tests/gtest/TestStrings.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/xpcom/tests/gtest/TestStrings.cpp b/xpcom/tests/gtest/TestStrings.cpp
index b1458ec6ce..450befc20d 100644
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -1183,11 +1183,9 @@ TEST_F(Strings, stringbuffer) {
memcpy(data, kData, sizeof(kData));
nsCString str;
- buf->ToString(sizeof(kData) - 1, str);
-
- nsStringBuffer* buf2;
- buf2 = nsStringBuffer::FromString(str);
+ str.Assign(buf, sizeof(kData) - 1);
+ nsStringBuffer* buf2 = str.GetStringBuffer();
EXPECT_EQ(buf, buf2);
}
@@ -1283,9 +1281,6 @@ TEST_F(Strings, string_tointeger) {
int32_t result = nsAutoCString(t->str).ToInteger(&rv, t->radix);
EXPECT_EQ(rv, t->rv);
EXPECT_EQ(result, t->result);
- result = nsAutoCString(t->str).ToInteger(&rv, t->radix);
- EXPECT_EQ(rv, t->rv);
- EXPECT_EQ(result, t->result);
}
}
@@ -2288,6 +2283,30 @@ TEST_F(Strings, printf) {
create_printf_strings(format, (char*)anotherString);
verify_printf_strings(expectedOutput);
}
+ {
+ const char* format = "RightJustify %8s";
+ const char* expectedOutput = "RightJustify foo";
+ create_printf_strings(format, "foo");
+ verify_printf_strings(expectedOutput);
+ }
+ {
+ const char* format = "LeftJustify %-8s";
+ const char* expectedOutput = "LeftJustify foo ";
+ create_printf_strings(format, "foo");
+ verify_printf_strings(expectedOutput);
+ }
+ {
+ const char* format = "RightJustify2 %*s";
+ const char* expectedOutput = "RightJustify2 foo";
+ create_printf_strings(format, 8, "foo");
+ verify_printf_strings(expectedOutput);
+ }
+ {
+ const char* format = "LeftJustify2 %-*s";
+ const char* expectedOutput = "LeftJustify2 foo ";
+ create_printf_strings(format, 8, "foo");
+ verify_printf_strings(expectedOutput);
+ }
}
// We don't need these macros following the printf test.