diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /xpcom/tests/gtest/TestStrings.cpp | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xpcom/tests/gtest/TestStrings.cpp')
-rw-r--r-- | xpcom/tests/gtest/TestStrings.cpp | 33 |
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. |