From 59203c63bb777a3bacec32fb8830fba33540e809 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:29 +0200 Subject: Adding upstream version 127.0. Signed-off-by: Daniel Baumann --- xpcom/tests/gtest/TestStrings.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'xpcom/tests/gtest/TestStrings.cpp') 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. -- cgit v1.2.3