1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:17:35 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -19,6 +19,7 @@ set(AK_TEST_SOURCES
TestCircularDuplexStream.cpp
TestCircularQueue.cpp
TestComplex.cpp
TestDeprecatedString.cpp
TestDisjointChunks.cpp
TestDistinctNumeric.cpp
TestDoublyLinkedList.cpp
@ -61,7 +62,6 @@ set(AK_TEST_SOURCES
TestSpan.cpp
TestStack.cpp
TestStdLibExtras.cpp
TestString.cpp
TestStringFloatingPointConversions.cpp
TestStringUtils.cpp
TestStringView.cpp

View file

@ -7,7 +7,7 @@
#include <LibTest/TestCase.h>
#include <AK/Base64.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <string.h>
TEST_CASE(test_decode)
@ -16,7 +16,7 @@ TEST_CASE(test_decode)
auto decoded_option = decode_base64(input);
EXPECT(!decoded_option.is_error());
auto decoded = decoded_option.release_value();
EXPECT(String::copy(decoded) == expected);
EXPECT(DeprecatedString::copy(decoded) == expected);
EXPECT(expected.length() <= calculate_base64_decoded_length(input.bytes()));
};
@ -43,7 +43,7 @@ TEST_CASE(test_encode)
{
auto encode_equal = [&](StringView input, StringView expected) {
auto encoded = encode_base64(input.bytes());
EXPECT(encoded == String(expected));
EXPECT(encoded == DeprecatedString(expected));
EXPECT_EQ(expected.length(), calculate_base64_encoded_length(input.bytes()));
};

View file

@ -7,7 +7,7 @@
#include <LibTest/TestCase.h>
#include <AK/BinaryHeap.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
TEST_CASE(construct)
{
@ -44,7 +44,7 @@ TEST_CASE(populate_int)
TEST_CASE(populate_string)
{
BinaryHeap<int, String, 5> strings;
BinaryHeap<int, DeprecatedString, 5> strings;
strings.insert(1, "ABC");
strings.insert(2, "DEF");
EXPECT_EQ(strings.size(), 2u);

View file

@ -49,20 +49,20 @@ TEST_CASE(array_doubles)
TEST_CASE(vector_strings)
{
Vector<String> strings;
Vector<DeprecatedString> strings;
strings.append("bat");
strings.append("cat");
strings.append("dog");
auto string_compare = [](String const& a, String const& b) -> int {
auto string_compare = [](DeprecatedString const& a, DeprecatedString const& b) -> int {
return strcmp(a.characters(), b.characters());
};
auto test1 = *binary_search(strings, String("bat"), nullptr, string_compare);
auto test2 = *binary_search(strings, String("cat"), nullptr, string_compare);
auto test3 = *binary_search(strings, String("dog"), nullptr, string_compare);
EXPECT_EQ(test1, String("bat"));
EXPECT_EQ(test2, String("cat"));
EXPECT_EQ(test3, String("dog"));
auto test1 = *binary_search(strings, DeprecatedString("bat"), nullptr, string_compare);
auto test2 = *binary_search(strings, DeprecatedString("cat"), nullptr, string_compare);
auto test3 = *binary_search(strings, DeprecatedString("dog"), nullptr, string_compare);
EXPECT_EQ(test1, DeprecatedString("bat"));
EXPECT_EQ(test2, DeprecatedString("cat"));
EXPECT_EQ(test3, DeprecatedString("dog"));
}
TEST_CASE(single_element)

View file

@ -7,8 +7,8 @@
#include <LibTest/TestCase.h>
#include <AK/CircularDeque.h>
#include <AK/DeprecatedString.h>
#include <AK/StdLibExtras.h>
#include <AK/String.h>
TEST_CASE(enqueue_begin)
{
@ -37,9 +37,9 @@ TEST_CASE(enqueue_begin)
TEST_CASE(enqueue_begin_being_moved_from)
{
CircularDeque<String, 2> strings;
CircularDeque<DeprecatedString, 2> strings;
String str { "test" };
DeprecatedString str { "test" };
strings.enqueue_begin(move(str));
EXPECT(str.is_null());
}

View file

@ -7,7 +7,7 @@
#include <LibTest/TestCase.h>
#include <AK/CircularQueue.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
TEST_CASE(basic)
{
@ -28,7 +28,7 @@ TEST_CASE(basic)
TEST_CASE(complex_type)
{
CircularQueue<String, 2> strings;
CircularQueue<DeprecatedString, 2> strings;
strings.enqueue("ABC");
strings.enqueue("DEF");
@ -44,7 +44,7 @@ TEST_CASE(complex_type)
TEST_CASE(complex_type_clear)
{
CircularQueue<String, 5> strings;
CircularQueue<DeprecatedString, 5> strings;
strings.enqueue("xxx");
strings.enqueue("xxx");
strings.enqueue("xxx");

View file

@ -6,28 +6,28 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <cstring>
TEST_CASE(construct_empty)
{
EXPECT(String().is_null());
EXPECT(String().is_empty());
EXPECT(!String().characters());
EXPECT(DeprecatedString().is_null());
EXPECT(DeprecatedString().is_empty());
EXPECT(!DeprecatedString().characters());
EXPECT(!String("").is_null());
EXPECT(String("").is_empty());
EXPECT(String("").characters() != nullptr);
EXPECT(!DeprecatedString("").is_null());
EXPECT(DeprecatedString("").is_empty());
EXPECT(DeprecatedString("").characters() != nullptr);
EXPECT(String("").impl() == String::empty().impl());
EXPECT(DeprecatedString("").impl() == DeprecatedString::empty().impl());
}
TEST_CASE(construct_contents)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
EXPECT(!test_string.is_empty());
EXPECT(!test_string.is_null());
EXPECT_EQ(test_string.length(), 6u);
@ -42,45 +42,45 @@ TEST_CASE(construct_contents)
TEST_CASE(equal)
{
EXPECT_NE(String::empty(), String {});
EXPECT_NE(DeprecatedString::empty(), DeprecatedString {});
}
TEST_CASE(compare)
{
EXPECT("a"sv < String("b"));
EXPECT(!("a"sv > String("b")));
EXPECT("b"sv > String("a"));
EXPECT(!("b"sv < String("b")));
EXPECT("a"sv >= String("a"));
EXPECT(!("a"sv >= String("b")));
EXPECT("a"sv <= String("a"));
EXPECT(!("b"sv <= String("a")));
EXPECT("a"sv < DeprecatedString("b"));
EXPECT(!("a"sv > DeprecatedString("b")));
EXPECT("b"sv > DeprecatedString("a"));
EXPECT(!("b"sv < DeprecatedString("b")));
EXPECT("a"sv >= DeprecatedString("a"));
EXPECT(!("a"sv >= DeprecatedString("b")));
EXPECT("a"sv <= DeprecatedString("a"));
EXPECT(!("b"sv <= DeprecatedString("a")));
EXPECT(String("a") > String());
EXPECT(!(String() > String("a")));
EXPECT(String() < String("a"));
EXPECT(!(String("a") < String()));
EXPECT(String("a") >= String());
EXPECT(!(String() >= String("a")));
EXPECT(String() <= String("a"));
EXPECT(!(String("a") <= String()));
EXPECT(DeprecatedString("a") > DeprecatedString());
EXPECT(!(DeprecatedString() > DeprecatedString("a")));
EXPECT(DeprecatedString() < DeprecatedString("a"));
EXPECT(!(DeprecatedString("a") < DeprecatedString()));
EXPECT(DeprecatedString("a") >= DeprecatedString());
EXPECT(!(DeprecatedString() >= DeprecatedString("a")));
EXPECT(DeprecatedString() <= DeprecatedString("a"));
EXPECT(!(DeprecatedString("a") <= DeprecatedString()));
EXPECT(!(String() > String()));
EXPECT(!(String() < String()));
EXPECT(String() >= String());
EXPECT(String() <= String());
EXPECT(!(DeprecatedString() > DeprecatedString()));
EXPECT(!(DeprecatedString() < DeprecatedString()));
EXPECT(DeprecatedString() >= DeprecatedString());
EXPECT(DeprecatedString() <= DeprecatedString());
}
TEST_CASE(index_access)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
EXPECT_EQ(test_string[0], 'A');
EXPECT_EQ(test_string[1], 'B');
}
TEST_CASE(starts_with)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
EXPECT(test_string.starts_with("AB"sv));
EXPECT(test_string.starts_with('A'));
EXPECT(!test_string.starts_with('B'));
@ -92,7 +92,7 @@ TEST_CASE(starts_with)
TEST_CASE(ends_with)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
EXPECT(test_string.ends_with("EF"sv));
EXPECT(test_string.ends_with('F'));
EXPECT(!test_string.ends_with('E'));
@ -104,7 +104,7 @@ TEST_CASE(ends_with)
TEST_CASE(copy_string)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
auto test_string_copy = test_string;
EXPECT_EQ(test_string, test_string_copy);
EXPECT_EQ(test_string.characters(), test_string_copy.characters());
@ -112,7 +112,7 @@ TEST_CASE(copy_string)
TEST_CASE(move_string)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
auto test_string_copy = test_string;
auto test_string_move = move(test_string_copy);
EXPECT_EQ(test_string, test_string_move);
@ -121,25 +121,25 @@ TEST_CASE(move_string)
TEST_CASE(repeated)
{
EXPECT_EQ(String::repeated('x', 0), "");
EXPECT_EQ(String::repeated('x', 1), "x");
EXPECT_EQ(String::repeated('x', 2), "xx");
EXPECT_EQ(DeprecatedString::repeated('x', 0), "");
EXPECT_EQ(DeprecatedString::repeated('x', 1), "x");
EXPECT_EQ(DeprecatedString::repeated('x', 2), "xx");
}
TEST_CASE(to_int)
{
EXPECT_EQ(String("123").to_int().value(), 123);
EXPECT_EQ(String("-123").to_int().value(), -123);
EXPECT_EQ(DeprecatedString("123").to_int().value(), 123);
EXPECT_EQ(DeprecatedString("-123").to_int().value(), -123);
}
TEST_CASE(to_lowercase)
{
EXPECT(String("ABC").to_lowercase() == "abc");
EXPECT(DeprecatedString("ABC").to_lowercase() == "abc");
}
TEST_CASE(to_uppercase)
{
EXPECT(String("AbC").to_uppercase() == "ABC");
EXPECT(DeprecatedString("AbC").to_uppercase() == "ABC");
}
TEST_CASE(flystring)
@ -151,7 +151,7 @@ TEST_CASE(flystring)
}
{
String a = "foo";
DeprecatedString a = "foo";
FlyString b = a;
StringBuilder builder;
builder.append('f');
@ -164,7 +164,7 @@ TEST_CASE(flystring)
TEST_CASE(replace)
{
String test_string = "Well, hello Friends!";
DeprecatedString test_string = "Well, hello Friends!";
test_string = test_string.replace("Friends"sv, "Testers"sv, ReplaceMode::FirstOnly);
EXPECT(test_string == "Well, hello Testers!");
@ -175,7 +175,7 @@ TEST_CASE(replace)
test_string = test_string.replace("!"sv, " :^)"sv, ReplaceMode::FirstOnly);
EXPECT(test_string == "We're, he'reo Testers :^)");
test_string = String("111._.111._.111");
test_string = DeprecatedString("111._.111._.111");
test_string = test_string.replace("111"sv, "|||"sv, ReplaceMode::All);
EXPECT(test_string == "|||._.|||._.|||");
@ -185,7 +185,7 @@ TEST_CASE(replace)
TEST_CASE(count)
{
String test_string = "Well, hello Friends!";
DeprecatedString test_string = "Well, hello Friends!";
u32 count = test_string.count("Friends"sv);
EXPECT(count == 1);
@ -195,7 +195,7 @@ TEST_CASE(count)
count = test_string.count("!"sv);
EXPECT(count == 1);
test_string = String("111._.111._.111");
test_string = DeprecatedString("111._.111._.111");
count = test_string.count("111"sv);
EXPECT(count == 3);
@ -205,7 +205,7 @@ TEST_CASE(count)
TEST_CASE(substring)
{
String test = "abcdef";
DeprecatedString test = "abcdef";
EXPECT_EQ(test.substring(0, 6), test);
EXPECT_EQ(test.substring(0, 3), "abc");
EXPECT_EQ(test.substring(3, 3), "def");
@ -215,7 +215,7 @@ TEST_CASE(substring)
TEST_CASE(split)
{
String test = "foo bar baz";
DeprecatedString test = "foo bar baz";
auto parts = test.split(' ');
EXPECT_EQ(parts.size(), 3u);
EXPECT_EQ(parts[0], "foo");
@ -259,7 +259,7 @@ TEST_CASE(builder_zero_initial_capacity)
TEST_CASE(find)
{
String a = "foobarbar";
DeprecatedString a = "foobarbar";
EXPECT_EQ(a.find("bar"sv), Optional<size_t> { 3 });
EXPECT_EQ(a.find("baz"sv), Optional<size_t> {});
EXPECT_EQ(a.find("bar"sv, 4), Optional<size_t> { 6 });
@ -275,7 +275,7 @@ TEST_CASE(find)
TEST_CASE(find_with_empty_needle)
{
String string = "";
DeprecatedString string = "";
EXPECT_EQ(string.find(""sv), 0u);
EXPECT_EQ(string.find_all(""sv), (Vector<size_t> { 0u }));
@ -286,30 +286,30 @@ TEST_CASE(find_with_empty_needle)
TEST_CASE(bijective_base)
{
EXPECT_EQ(String::bijective_base_from(0), "A");
EXPECT_EQ(String::bijective_base_from(25), "Z");
EXPECT_EQ(String::bijective_base_from(26), "AA");
EXPECT_EQ(String::bijective_base_from(52), "BA");
EXPECT_EQ(String::bijective_base_from(704), "ABC");
EXPECT_EQ(DeprecatedString::bijective_base_from(0), "A");
EXPECT_EQ(DeprecatedString::bijective_base_from(25), "Z");
EXPECT_EQ(DeprecatedString::bijective_base_from(26), "AA");
EXPECT_EQ(DeprecatedString::bijective_base_from(52), "BA");
EXPECT_EQ(DeprecatedString::bijective_base_from(704), "ABC");
}
TEST_CASE(roman_numerals)
{
auto zero = String::roman_number_from(0);
auto zero = DeprecatedString::roman_number_from(0);
EXPECT_EQ(zero, "");
auto one = String::roman_number_from(1);
auto one = DeprecatedString::roman_number_from(1);
EXPECT_EQ(one, "I");
auto nine = String::roman_number_from(9);
auto nine = DeprecatedString::roman_number_from(9);
EXPECT_EQ(nine, "IX");
auto fourty_eight = String::roman_number_from(48);
auto fourty_eight = DeprecatedString::roman_number_from(48);
EXPECT_EQ(fourty_eight, "XLVIII");
auto one_thousand_nine_hundred_ninety_eight = String::roman_number_from(1998);
auto one_thousand_nine_hundred_ninety_eight = DeprecatedString::roman_number_from(1998);
EXPECT_EQ(one_thousand_nine_hundred_ninety_eight, "MCMXCVIII");
auto four_thousand = String::roman_number_from(4000);
auto four_thousand = DeprecatedString::roman_number_from(4000);
EXPECT_EQ(four_thousand, "4000");
}

View file

@ -6,9 +6,9 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/DisjointChunks.h>
#include <AK/FixedArray.h>
#include <AK/String.h>
#include <AK/Vector.h>
TEST_CASE(basic)

View file

@ -145,9 +145,9 @@ TEST_CASE(cast)
TEST_CASE(formatter)
{
EXPECT_EQ(String::formatted("{}", FixedPoint<16>(123.456)), "123.455993"sv);
EXPECT_EQ(String::formatted("{}", FixedPoint<16>(-123.456)), "-123.455994"sv);
EXPECT_EQ(String::formatted("{}", FixedPoint<4>(123.456)), "123.4375"sv);
EXPECT_EQ(String::formatted("{}", FixedPoint<4>(-123.456)), "-123.4375"sv);
EXPECT_EQ(String::formatted("{}", FixedPoint<16> {}), "0"sv);
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(123.456)), "123.455993"sv);
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(-123.456)), "-123.455994"sv);
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<4>(123.456)), "123.4375"sv);
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<4>(-123.456)), "-123.4375"sv);
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16> {}), "0"sv);
}

View file

@ -6,7 +6,7 @@
#include <LibTest/TestCase.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <math.h>
@ -20,42 +20,42 @@ TEST_CASE(is_integral_works_properly)
TEST_CASE(format_string_literals)
{
EXPECT_EQ(String::formatted("prefix-{}-suffix", "abc"), "prefix-abc-suffix");
EXPECT_EQ(String::formatted("{}{}{}", "a", "b", "c"), "abc");
EXPECT_EQ(DeprecatedString::formatted("prefix-{}-suffix", "abc"), "prefix-abc-suffix");
EXPECT_EQ(DeprecatedString::formatted("{}{}{}", "a", "b", "c"), "abc");
}
TEST_CASE(format_integers)
{
EXPECT_EQ(String::formatted("{}", 42u), "42");
EXPECT_EQ(String::formatted("{:4}", 42u), " 42");
EXPECT_EQ(String::formatted("{:08}", 42u), "00000042");
EXPECT_EQ(String::formatted("{:7}", -17), " -17");
EXPECT_EQ(String::formatted("{}", -17), "-17");
EXPECT_EQ(String::formatted("{:04}", 13), "0013");
EXPECT_EQ(String::formatted("{:08x}", 4096), "00001000");
EXPECT_EQ(String::formatted("{:x}", 0x1111222233334444ull), "1111222233334444");
EXPECT_EQ(String::formatted("{:4}", 12345678), "12345678");
EXPECT_EQ(DeprecatedString::formatted("{}", 42u), "42");
EXPECT_EQ(DeprecatedString::formatted("{:4}", 42u), " 42");
EXPECT_EQ(DeprecatedString::formatted("{:08}", 42u), "00000042");
EXPECT_EQ(DeprecatedString::formatted("{:7}", -17), " -17");
EXPECT_EQ(DeprecatedString::formatted("{}", -17), "-17");
EXPECT_EQ(DeprecatedString::formatted("{:04}", 13), "0013");
EXPECT_EQ(DeprecatedString::formatted("{:08x}", 4096), "00001000");
EXPECT_EQ(DeprecatedString::formatted("{:x}", 0x1111222233334444ull), "1111222233334444");
EXPECT_EQ(DeprecatedString::formatted("{:4}", 12345678), "12345678");
}
TEST_CASE(reorder_format_arguments)
{
EXPECT_EQ(String::formatted("{1}{0}", "a", "b"), "ba");
EXPECT_EQ(String::formatted("{0}{1}", "a", "b"), "ab");
EXPECT_EQ(DeprecatedString::formatted("{1}{0}", "a", "b"), "ba");
EXPECT_EQ(DeprecatedString::formatted("{0}{1}", "a", "b"), "ab");
// Compiletime check bypass: ignoring a passed argument.
EXPECT_EQ(String::formatted("{0}{0}{0}"sv, "a", "b"), "aaa");
EXPECT_EQ(DeprecatedString::formatted("{0}{0}{0}"sv, "a", "b"), "aaa");
// Compiletime check bypass: ignoring a passed argument.
EXPECT_EQ(String::formatted("{1}{}{0}"sv, "a", "b", "c"), "baa");
EXPECT_EQ(DeprecatedString::formatted("{1}{}{0}"sv, "a", "b", "c"), "baa");
}
TEST_CASE(escape_braces)
{
EXPECT_EQ(String::formatted("{{{}", "foo"), "{foo");
EXPECT_EQ(String::formatted("{}}}", "bar"), "bar}");
EXPECT_EQ(DeprecatedString::formatted("{{{}", "foo"), "{foo");
EXPECT_EQ(DeprecatedString::formatted("{}}}", "bar"), "bar}");
}
TEST_CASE(everything)
{
EXPECT_EQ(String::formatted("{{{:04}/{}/{0:8}/{1}", 42u, "foo"), "{0042/foo/ 42/foo");
EXPECT_EQ(DeprecatedString::formatted("{{{:04}/{}/{0:8}/{1}", 42u, "foo"), "{0042/foo/ 42/foo");
}
TEST_CASE(string_builder)
@ -69,85 +69,85 @@ TEST_CASE(string_builder)
TEST_CASE(format_without_arguments)
{
EXPECT_EQ(String::formatted("foo"), "foo");
EXPECT_EQ(DeprecatedString::formatted("foo"), "foo");
}
TEST_CASE(format_upper_case_integer)
{
EXPECT_EQ(String::formatted("{:4X}", 0xff), " FF");
EXPECT_EQ(String::formatted("{:#4X}", 0xff), "0XFF");
EXPECT_EQ(DeprecatedString::formatted("{:4X}", 0xff), " FF");
EXPECT_EQ(DeprecatedString::formatted("{:#4X}", 0xff), "0XFF");
EXPECT_EQ(String::formatted("{:b}", 0xff), "11111111");
EXPECT_EQ(String::formatted("{:B}", 0xff), "11111111");
EXPECT_EQ(String::formatted("{:#b}", 0xff), "0b11111111");
EXPECT_EQ(DeprecatedString::formatted("{:b}", 0xff), "11111111");
EXPECT_EQ(DeprecatedString::formatted("{:B}", 0xff), "11111111");
EXPECT_EQ(DeprecatedString::formatted("{:#b}", 0xff), "0b11111111");
}
TEST_CASE(format_aligned)
{
EXPECT_EQ(String::formatted("{:*<8}", 13), "13******");
EXPECT_EQ(String::formatted("{:*^8}", 13), "***13***");
EXPECT_EQ(String::formatted("{:*>8}", 13), "******13");
EXPECT_EQ(String::formatted("{:*>+8}", 13), "*****+13");
EXPECT_EQ(String::formatted("{:*^ 8}", 13), "** 13***");
EXPECT_EQ(DeprecatedString::formatted("{:*<8}", 13), "13******");
EXPECT_EQ(DeprecatedString::formatted("{:*^8}", 13), "***13***");
EXPECT_EQ(DeprecatedString::formatted("{:*>8}", 13), "******13");
EXPECT_EQ(DeprecatedString::formatted("{:*>+8}", 13), "*****+13");
EXPECT_EQ(DeprecatedString::formatted("{:*^ 8}", 13), "** 13***");
}
TEST_CASE(format_octal)
{
EXPECT_EQ(String::formatted("{:o}", 0744), "744");
EXPECT_EQ(String::formatted("{:#o}", 0744), "0744");
EXPECT_EQ(DeprecatedString::formatted("{:o}", 0744), "744");
EXPECT_EQ(DeprecatedString::formatted("{:#o}", 0744), "0744");
}
TEST_CASE(zero_pad)
{
EXPECT_EQ(String::formatted("{: <010}", 42), "42 ");
EXPECT_EQ(String::formatted("{:010}", 42), "0000000042");
EXPECT_EQ(String::formatted("{:/^010}", 42), "////42////");
EXPECT_EQ(String::formatted("{:04x}", -32), "-0020");
EXPECT_EQ(String::formatted("{:#06x}", -64), "-0x000040");
EXPECT_EQ(DeprecatedString::formatted("{: <010}", 42), "42 ");
EXPECT_EQ(DeprecatedString::formatted("{:010}", 42), "0000000042");
EXPECT_EQ(DeprecatedString::formatted("{:/^010}", 42), "////42////");
EXPECT_EQ(DeprecatedString::formatted("{:04x}", -32), "-0020");
EXPECT_EQ(DeprecatedString::formatted("{:#06x}", -64), "-0x000040");
}
TEST_CASE(replacement_field)
{
EXPECT_EQ(String::formatted("{:*>{1}}", 13, static_cast<size_t>(10)), "********13");
EXPECT_EQ(String::formatted("{:*<{1}}", 7, 4), "7***");
EXPECT_EQ(DeprecatedString::formatted("{:*>{1}}", 13, static_cast<size_t>(10)), "********13");
EXPECT_EQ(DeprecatedString::formatted("{:*<{1}}", 7, 4), "7***");
// Compiletime check bypass: intentionally ignoring extra arguments
EXPECT_EQ(String::formatted("{:{2}}"sv, -5, 8, 16), " -5");
EXPECT_EQ(String::formatted("{{{:*^{1}}}}", 1, 3), "{*1*}");
EXPECT_EQ(String::formatted("{:0{}}", 1, 3), "001");
EXPECT_EQ(DeprecatedString::formatted("{:{2}}"sv, -5, 8, 16), " -5");
EXPECT_EQ(DeprecatedString::formatted("{{{:*^{1}}}}", 1, 3), "{*1*}");
EXPECT_EQ(DeprecatedString::formatted("{:0{}}", 1, 3), "001");
}
TEST_CASE(replacement_field_regression)
{
// FIXME: Compiletime check bypass: cannot parse '}}' correctly.
EXPECT_EQ(String::formatted("{:{}}"sv, "", static_cast<unsigned long>(6)), " ");
EXPECT_EQ(DeprecatedString::formatted("{:{}}"sv, "", static_cast<unsigned long>(6)), " ");
}
TEST_CASE(complex_string_specifiers)
{
EXPECT_EQ(String::formatted("{:.8}", "123456789"), "12345678");
EXPECT_EQ(String::formatted("{:9}", "abcd"), "abcd ");
EXPECT_EQ(String::formatted("{:>9}", "abcd"), " abcd");
EXPECT_EQ(String::formatted("{:^9}", "abcd"), " abcd ");
EXPECT_EQ(String::formatted("{:4.6}", "a"), "a ");
EXPECT_EQ(String::formatted("{:4.6}", "abcdef"), "abcdef");
EXPECT_EQ(String::formatted("{:4.6}", "abcdefghi"), "abcdef");
EXPECT_EQ(DeprecatedString::formatted("{:.8}", "123456789"), "12345678");
EXPECT_EQ(DeprecatedString::formatted("{:9}", "abcd"), "abcd ");
EXPECT_EQ(DeprecatedString::formatted("{:>9}", "abcd"), " abcd");
EXPECT_EQ(DeprecatedString::formatted("{:^9}", "abcd"), " abcd ");
EXPECT_EQ(DeprecatedString::formatted("{:4.6}", "a"), "a ");
EXPECT_EQ(DeprecatedString::formatted("{:4.6}", "abcdef"), "abcdef");
EXPECT_EQ(DeprecatedString::formatted("{:4.6}", "abcdefghi"), "abcdef");
}
TEST_CASE(cast_integer_to_character)
{
EXPECT_EQ(String::formatted("{:c}", static_cast<int>('a')), "a");
EXPECT_EQ(String::formatted("{:c}", static_cast<unsigned int>('f')), "f");
EXPECT_EQ(DeprecatedString::formatted("{:c}", static_cast<int>('a')), "a");
EXPECT_EQ(DeprecatedString::formatted("{:c}", static_cast<unsigned int>('f')), "f");
}
TEST_CASE(boolean_values)
{
EXPECT_EQ(String::formatted("{}", true), "true");
EXPECT_EQ(String::formatted("{}", false), "false");
EXPECT_EQ(String::formatted("{:6}", true), "true ");
EXPECT_EQ(String::formatted("{:>4}", false), "false");
EXPECT_EQ(String::formatted("{:d}", false), "0");
EXPECT_EQ(String::formatted("{:d}", true), "1");
EXPECT_EQ(String::formatted("{:#08x}", true), "0x00000001");
EXPECT_EQ(DeprecatedString::formatted("{}", true), "true");
EXPECT_EQ(DeprecatedString::formatted("{}", false), "false");
EXPECT_EQ(DeprecatedString::formatted("{:6}", true), "true ");
EXPECT_EQ(DeprecatedString::formatted("{:>4}", false), "false");
EXPECT_EQ(DeprecatedString::formatted("{:d}", false), "0");
EXPECT_EQ(DeprecatedString::formatted("{:d}", true), "1");
EXPECT_EQ(DeprecatedString::formatted("{:#08x}", true), "0x00000001");
}
TEST_CASE(pointers)
@ -155,13 +155,13 @@ TEST_CASE(pointers)
void* ptr = reinterpret_cast<void*>(0x4000);
if (sizeof(void*) == 4) {
EXPECT_EQ(String::formatted("{:p}", 32), "0x00000020");
EXPECT_EQ(String::formatted("{:p}", ptr), "0x00004000");
EXPECT_EQ(String::formatted("{}", ptr), "0x00004000");
EXPECT_EQ(DeprecatedString::formatted("{:p}", 32), "0x00000020");
EXPECT_EQ(DeprecatedString::formatted("{:p}", ptr), "0x00004000");
EXPECT_EQ(DeprecatedString::formatted("{}", ptr), "0x00004000");
} else if (sizeof(void*) == 8) {
EXPECT_EQ(String::formatted("{:p}", 32), "0x0000000000000020");
EXPECT_EQ(String::formatted("{:p}", ptr), "0x0000000000004000");
EXPECT_EQ(String::formatted("{}", ptr), "0x0000000000004000");
EXPECT_EQ(DeprecatedString::formatted("{:p}", 32), "0x0000000000000020");
EXPECT_EQ(DeprecatedString::formatted("{:p}", ptr), "0x0000000000004000");
EXPECT_EQ(DeprecatedString::formatted("{}", ptr), "0x0000000000004000");
} else {
VERIFY_NOT_REACHED();
}
@ -173,12 +173,12 @@ TEST_CASE(pointers)
// This is a bit scary, thus this test. At least this test should fail in this case.
TEST_CASE(ensure_that_format_works)
{
if (String::formatted("FAIL") != "FAIL") {
if (DeprecatedString::formatted("FAIL") != "FAIL") {
fprintf(stderr, "FAIL\n");
exit(1);
}
if (String::formatted("{} FAIL {}", 1, 2) != "1 FAIL 2") {
if (DeprecatedString::formatted("{} FAIL {}", 1, 2) != "1 FAIL 2") {
fprintf(stderr, "FAIL\n");
exit(1);
}
@ -187,13 +187,13 @@ TEST_CASE(ensure_that_format_works)
TEST_CASE(format_string_literal_as_pointer)
{
char const* literal = "abc";
EXPECT_EQ(String::formatted("{:p}", literal), String::formatted("{:p}", reinterpret_cast<FlatPtr>(literal)));
EXPECT_EQ(DeprecatedString::formatted("{:p}", literal), DeprecatedString::formatted("{:p}", reinterpret_cast<FlatPtr>(literal)));
}
TEST_CASE(format_character)
{
char a = 'a';
EXPECT_EQ(String::formatted("{}", true ? a : 'b'), "a");
EXPECT_EQ(DeprecatedString::formatted("{}", true ? a : 'b'), "a");
}
struct A {
@ -210,8 +210,8 @@ struct AK::Formatter<B> : Formatter<StringView> {
TEST_CASE(format_if_supported)
{
EXPECT_EQ(String::formatted("{}", FormatIfSupported { A {} }), "?");
EXPECT_EQ(String::formatted("{}", FormatIfSupported { B {} }), "B");
EXPECT_EQ(DeprecatedString::formatted("{}", FormatIfSupported { A {} }), "?");
EXPECT_EQ(DeprecatedString::formatted("{}", FormatIfSupported { B {} }), "B");
}
TEST_CASE(file_descriptor)
@ -239,46 +239,46 @@ TEST_CASE(file_descriptor)
TEST_CASE(floating_point_numbers)
{
EXPECT_EQ(String::formatted("{}", 1.12), "1.12");
EXPECT_EQ(String::formatted("{}", 1.), "1");
EXPECT_EQ(String::formatted("{:.3}", 1.12), "1.12");
EXPECT_EQ(String::formatted("{:.1}", 1.12), "1.1");
EXPECT_EQ(String::formatted("{}", -1.12), "-1.12");
EXPECT_EQ(DeprecatedString::formatted("{}", 1.12), "1.12");
EXPECT_EQ(DeprecatedString::formatted("{}", 1.), "1");
EXPECT_EQ(DeprecatedString::formatted("{:.3}", 1.12), "1.12");
EXPECT_EQ(DeprecatedString::formatted("{:.1}", 1.12), "1.1");
EXPECT_EQ(DeprecatedString::formatted("{}", -1.12), "-1.12");
EXPECT_EQ(String::formatted("{}", NAN), "nan");
EXPECT_EQ(String::formatted("{}", INFINITY), "inf");
EXPECT_EQ(String::formatted("{}", -INFINITY), "-inf");
EXPECT_EQ(DeprecatedString::formatted("{}", NAN), "nan");
EXPECT_EQ(DeprecatedString::formatted("{}", INFINITY), "inf");
EXPECT_EQ(DeprecatedString::formatted("{}", -INFINITY), "-inf");
// FIXME: There is always the question what we mean with the width field. Do we mean significant digits?
// Do we mean the whole width? This is what was the simplest to implement:
EXPECT_EQ(String::formatted("{:x>5.1}", 1.12), "xx1.1");
EXPECT_EQ(DeprecatedString::formatted("{:x>5.1}", 1.12), "xx1.1");
}
TEST_CASE(no_precision_no_trailing_number)
{
EXPECT_EQ(String::formatted("{:.0}", 0.1), "0");
EXPECT_EQ(DeprecatedString::formatted("{:.0}", 0.1), "0");
}
TEST_CASE(yay_this_implementation_sucks)
{
EXPECT_EQ(String::formatted("{:.0}", .99999999999), "0");
EXPECT_EQ(DeprecatedString::formatted("{:.0}", .99999999999), "0");
}
TEST_CASE(precision_with_trailing_zeros)
{
EXPECT_EQ(String::formatted("{:0.3}", 1.12), "1.120");
EXPECT_EQ(String::formatted("{:0.1}", 1.12), "1.1");
EXPECT_EQ(DeprecatedString::formatted("{:0.3}", 1.12), "1.120");
EXPECT_EQ(DeprecatedString::formatted("{:0.1}", 1.12), "1.1");
}
TEST_CASE(magnitude_less_than_zero)
{
EXPECT_EQ(String::formatted("{}", -0.654), "-0.654");
EXPECT_EQ(String::formatted("{}", 0.654), "0.654");
EXPECT_EQ(DeprecatedString::formatted("{}", -0.654), "-0.654");
EXPECT_EQ(DeprecatedString::formatted("{}", 0.654), "0.654");
}
TEST_CASE(format_nullptr)
{
EXPECT_EQ(String::formatted("{}", nullptr), String::formatted("{:p}", static_cast<FlatPtr>(0)));
EXPECT_EQ(DeprecatedString::formatted("{}", nullptr), DeprecatedString::formatted("{:p}", static_cast<FlatPtr>(0)));
}
struct C {
@ -294,12 +294,12 @@ struct AK::Formatter<C> : AK::Formatter<FormatString> {
TEST_CASE(use_format_string_formatter)
{
EXPECT_EQ(String::formatted("{:*<10}", C { 42 }), "C(i=42)***");
EXPECT_EQ(DeprecatedString::formatted("{:*<10}", C { 42 }), "C(i=42)***");
}
TEST_CASE(long_long_regression)
{
EXPECT_EQ(String::formatted("{}", 0x0123456789abcdefLL), "81985529216486895");
EXPECT_EQ(DeprecatedString::formatted("{}", 0x0123456789abcdefLL), "81985529216486895");
StringBuilder builder;
AK::FormatBuilder fmtbuilder { builder };
@ -310,38 +310,38 @@ TEST_CASE(long_long_regression)
TEST_CASE(hex_dump)
{
EXPECT_EQ(String::formatted("{:hex-dump}", "0000"), "30303030");
EXPECT_EQ(String::formatted("{:>4hex-dump}", "0000"), "30303030 0000");
EXPECT_EQ(String::formatted("{:>2hex-dump}", "0000"), "3030 00\n3030 00");
EXPECT_EQ(String::formatted("{:*>4hex-dump}", "0000"), "30303030****0000");
EXPECT_EQ(DeprecatedString::formatted("{:hex-dump}", "0000"), "30303030");
EXPECT_EQ(DeprecatedString::formatted("{:>4hex-dump}", "0000"), "30303030 0000");
EXPECT_EQ(DeprecatedString::formatted("{:>2hex-dump}", "0000"), "3030 00\n3030 00");
EXPECT_EQ(DeprecatedString::formatted("{:*>4hex-dump}", "0000"), "30303030****0000");
}
TEST_CASE(vector_format)
{
{
Vector<int> v { 1, 2, 3, 4 };
EXPECT_EQ(String::formatted("{}", v), "[ 1, 2, 3, 4 ]");
EXPECT_EQ(DeprecatedString::formatted("{}", v), "[ 1, 2, 3, 4 ]");
}
{
Vector<StringView> v { "1"sv, "2"sv, "3"sv, "4"sv };
EXPECT_EQ(String::formatted("{}", v), "[ 1, 2, 3, 4 ]");
EXPECT_EQ(DeprecatedString::formatted("{}", v), "[ 1, 2, 3, 4 ]");
}
{
Vector<Vector<String>> v { { "1"sv, "2"sv }, { "3"sv, "4"sv } };
EXPECT_EQ(String::formatted("{}", v), "[ [ 1, 2 ], [ 3, 4 ] ]");
Vector<Vector<DeprecatedString>> v { { "1"sv, "2"sv }, { "3"sv, "4"sv } };
EXPECT_EQ(DeprecatedString::formatted("{}", v), "[ [ 1, 2 ], [ 3, 4 ] ]");
}
}
TEST_CASE(format_wchar)
{
EXPECT_EQ(String::formatted("{}", L'a'), "a");
EXPECT_EQ(String::formatted("{}", L'\U0001F41E'), "\xF0\x9F\x90\x9E");
EXPECT_EQ(String::formatted("{:x}", L'a'), "61");
EXPECT_EQ(String::formatted("{:x}", L'\U0001F41E'), "1f41e");
EXPECT_EQ(String::formatted("{:d}", L'a'), "97");
EXPECT_EQ(String::formatted("{:d}", L'\U0001F41E'), "128030");
EXPECT_EQ(DeprecatedString::formatted("{}", L'a'), "a");
EXPECT_EQ(DeprecatedString::formatted("{}", L'\U0001F41E'), "\xF0\x9F\x90\x9E");
EXPECT_EQ(DeprecatedString::formatted("{:x}", L'a'), "61");
EXPECT_EQ(DeprecatedString::formatted("{:x}", L'\U0001F41E'), "1f41e");
EXPECT_EQ(DeprecatedString::formatted("{:d}", L'a'), "97");
EXPECT_EQ(DeprecatedString::formatted("{:d}", L'\U0001F41E'), "128030");
EXPECT_EQ(String::formatted("{:6}", L'a'), "a ");
EXPECT_EQ(String::formatted("{:6d}", L'a'), " 97");
EXPECT_EQ(String::formatted("{:#x}", L'\U0001F41E'), "0x1f41e");
EXPECT_EQ(DeprecatedString::formatted("{:6}", L'a'), "a ");
EXPECT_EQ(DeprecatedString::formatted("{:6d}", L'a'), " 97");
EXPECT_EQ(DeprecatedString::formatted("{:#x}", L'\U0001F41E'), "0x1f41e");
}

View file

@ -6,9 +6,9 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/String.h>
TEST_CASE(construct)
{
@ -19,7 +19,7 @@ TEST_CASE(construct)
TEST_CASE(construct_from_initializer_list)
{
HashMap<int, String> number_to_string {
HashMap<int, DeprecatedString> number_to_string {
{ 1, "One" },
{ 2, "Two" },
{ 3, "Three" },
@ -30,7 +30,7 @@ TEST_CASE(construct_from_initializer_list)
TEST_CASE(populate)
{
HashMap<int, String> number_to_string;
HashMap<int, DeprecatedString> number_to_string;
number_to_string.set(1, "One");
number_to_string.set(2, "Two");
number_to_string.set(3, "Three");
@ -41,7 +41,7 @@ TEST_CASE(populate)
TEST_CASE(range_loop)
{
HashMap<int, String> number_to_string;
HashMap<int, DeprecatedString> number_to_string;
EXPECT_EQ(number_to_string.set(1, "One"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(number_to_string.set(2, "Two"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(number_to_string.set(3, "Three"), AK::HashSetResult::InsertedNewEntry);
@ -56,7 +56,7 @@ TEST_CASE(range_loop)
TEST_CASE(map_remove)
{
HashMap<int, String> number_to_string;
HashMap<int, DeprecatedString> number_to_string;
EXPECT_EQ(number_to_string.set(1, "One"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(number_to_string.set(2, "Two"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(number_to_string.set(3, "Three"), AK::HashSetResult::InsertedNewEntry);
@ -73,7 +73,7 @@ TEST_CASE(map_remove)
TEST_CASE(remove_all_matching)
{
HashMap<int, String> map;
HashMap<int, DeprecatedString> map;
map.set(1, "One");
map.set(2, "Two");
@ -82,27 +82,27 @@ TEST_CASE(remove_all_matching)
EXPECT_EQ(map.size(), 4u);
EXPECT_EQ(map.remove_all_matching([&](int key, String const& value) { return key == 1 || value == "Two"; }), true);
EXPECT_EQ(map.remove_all_matching([&](int key, DeprecatedString const& value) { return key == 1 || value == "Two"; }), true);
EXPECT_EQ(map.size(), 2u);
EXPECT_EQ(map.remove_all_matching([&](int, String const&) { return false; }), false);
EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return false; }), false);
EXPECT_EQ(map.size(), 2u);
EXPECT(map.contains(3));
EXPECT(map.contains(4));
EXPECT_EQ(map.remove_all_matching([&](int, String const&) { return true; }), true);
EXPECT_EQ(map.remove_all_matching([&](int, String const&) { return false; }), false);
EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return true; }), true);
EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return false; }), false);
EXPECT(map.is_empty());
EXPECT_EQ(map.remove_all_matching([&](int, String const&) { return true; }), false);
EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return true; }), false);
}
TEST_CASE(case_insensitive)
{
HashMap<String, int, CaseInsensitiveStringTraits> casemap;
EXPECT_EQ(String("nickserv").to_lowercase(), String("NickServ").to_lowercase());
HashMap<DeprecatedString, int, CaseInsensitiveStringTraits> casemap;
EXPECT_EQ(DeprecatedString("nickserv").to_lowercase(), DeprecatedString("NickServ").to_lowercase());
EXPECT_EQ(casemap.set("nickserv", 3), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(casemap.set("NickServ", 3), AK::HashSetResult::ReplacedExistingEntry);
EXPECT_EQ(casemap.size(), 1u);
@ -111,11 +111,11 @@ TEST_CASE(case_insensitive)
TEST_CASE(hashmap_of_nonnullownptr_get)
{
struct Object {
Object(String const& s)
Object(DeprecatedString const& s)
: string(s)
{
}
String string;
DeprecatedString string;
};
HashMap<int, NonnullOwnPtr<Object>> objects;
@ -142,16 +142,16 @@ TEST_CASE(hashmap_of_nonnullownptr_get)
TEST_CASE(many_strings)
{
HashMap<String, int> strings;
HashMap<DeprecatedString, int> strings;
for (int i = 0; i < 999; ++i) {
EXPECT_EQ(strings.set(String::number(i), i), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.set(DeprecatedString::number(i), i), AK::HashSetResult::InsertedNewEntry);
}
EXPECT_EQ(strings.size(), 999u);
for (auto& it : strings) {
EXPECT_EQ(it.key.to_int().value(), it.value);
}
for (int i = 0; i < 999; ++i) {
EXPECT_EQ(strings.remove(String::number(i)), true);
EXPECT_EQ(strings.remove(DeprecatedString::number(i)), true);
}
EXPECT_EQ(strings.is_empty(), true);
}
@ -204,7 +204,7 @@ TEST_CASE(basic_contains)
TEST_CASE(in_place_rehashing_ordered_loop_bug)
{
OrderedHashMap<String, String> map;
OrderedHashMap<DeprecatedString, DeprecatedString> map;
map.set("yt.innertube::nextId", "");
map.set("yt.innertube::requests", "");
map.remove("yt.innertube::nextId");

View file

@ -6,9 +6,9 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/HashTable.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/String.h>
TEST_CASE(construct)
{
@ -44,7 +44,7 @@ TEST_CASE(move_is_not_swap)
TEST_CASE(populate)
{
HashTable<String> strings;
HashTable<DeprecatedString> strings;
strings.set("One");
strings.set("Two");
strings.set("Three");
@ -55,7 +55,7 @@ TEST_CASE(populate)
TEST_CASE(range_loop)
{
HashTable<String> strings;
HashTable<DeprecatedString> strings;
EXPECT_EQ(strings.set("One"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.set("Two"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.set("Three"), AK::HashSetResult::InsertedNewEntry);
@ -70,7 +70,7 @@ TEST_CASE(range_loop)
TEST_CASE(table_remove)
{
HashTable<String> strings;
HashTable<DeprecatedString> strings;
EXPECT_EQ(strings.set("One"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.set("Two"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.set("Three"), AK::HashSetResult::InsertedNewEntry);
@ -113,8 +113,8 @@ TEST_CASE(remove_all_matching)
TEST_CASE(case_insensitive)
{
HashTable<String, CaseInsensitiveStringTraits> casetable;
EXPECT_EQ(String("nickserv").to_lowercase(), String("NickServ").to_lowercase());
HashTable<DeprecatedString, CaseInsensitiveStringTraits> casetable;
EXPECT_EQ(DeprecatedString("nickserv").to_lowercase(), DeprecatedString("NickServ").to_lowercase());
EXPECT_EQ(casetable.set("nickserv"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(casetable.set("NickServ"), AK::HashSetResult::ReplacedExistingEntry);
EXPECT_EQ(casetable.size(), 1u);
@ -122,33 +122,33 @@ TEST_CASE(case_insensitive)
TEST_CASE(many_strings)
{
HashTable<String> strings;
HashTable<DeprecatedString> strings;
for (int i = 0; i < 999; ++i) {
EXPECT_EQ(strings.set(String::number(i)), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry);
}
EXPECT_EQ(strings.size(), 999u);
for (int i = 0; i < 999; ++i) {
EXPECT_EQ(strings.remove(String::number(i)), true);
EXPECT_EQ(strings.remove(DeprecatedString::number(i)), true);
}
EXPECT_EQ(strings.is_empty(), true);
}
TEST_CASE(many_collisions)
{
struct StringCollisionTraits : public GenericTraits<String> {
static unsigned hash(String const&) { return 0; }
struct StringCollisionTraits : public GenericTraits<DeprecatedString> {
static unsigned hash(DeprecatedString const&) { return 0; }
};
HashTable<String, StringCollisionTraits> strings;
HashTable<DeprecatedString, StringCollisionTraits> strings;
for (int i = 0; i < 999; ++i) {
EXPECT_EQ(strings.set(String::number(i)), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry);
}
EXPECT_EQ(strings.set("foo"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.size(), 1000u);
for (int i = 0; i < 999; ++i) {
EXPECT_EQ(strings.remove(String::number(i)), true);
EXPECT_EQ(strings.remove(DeprecatedString::number(i)), true);
}
// FIXME: Doing this with an "EXPECT_NOT_EQ" would be cleaner.
@ -157,24 +157,24 @@ TEST_CASE(many_collisions)
TEST_CASE(space_reuse)
{
struct StringCollisionTraits : public GenericTraits<String> {
static unsigned hash(String const&) { return 0; }
struct StringCollisionTraits : public GenericTraits<DeprecatedString> {
static unsigned hash(DeprecatedString const&) { return 0; }
};
HashTable<String, StringCollisionTraits> strings;
HashTable<DeprecatedString, StringCollisionTraits> strings;
// Add a few items to allow it to do initial resizing.
EXPECT_EQ(strings.set("0"), AK::HashSetResult::InsertedNewEntry);
for (int i = 1; i < 5; ++i) {
EXPECT_EQ(strings.set(String::number(i)), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.remove(String::number(i - 1)), true);
EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.remove(DeprecatedString::number(i - 1)), true);
}
auto capacity = strings.capacity();
for (int i = 5; i < 999; ++i) {
EXPECT_EQ(strings.set(String::number(i)), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.remove(String::number(i - 1)), true);
EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(strings.remove(DeprecatedString::number(i - 1)), true);
}
EXPECT_EQ(strings.capacity(), capacity);
@ -300,7 +300,7 @@ BENCHMARK_CASE(benchmark_thrashing)
TEST_CASE(reinsertion)
{
OrderedHashTable<String> map;
OrderedHashTable<DeprecatedString> map;
map.set("ytidb::LAST_RESULT_ENTRY_KEY");
map.set("__sak");
map.remove("__sak");

View file

@ -6,15 +6,15 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
TEST_CASE(load_form)
{
String raw_form_json = R"(
DeprecatedString raw_form_json = R"(
{
"name": "Form1",
"widgets": [
@ -294,7 +294,7 @@ private:
TEST_CASE(fallible_json_object_for_each)
{
String raw_json = R"(
DeprecatedString raw_json = R"(
{
"name": "anon",
"home": "/home/anon",
@ -334,7 +334,7 @@ TEST_CASE(fallible_json_object_for_each)
TEST_CASE(fallible_json_array_for_each)
{
String raw_json = R"(
DeprecatedString raw_json = R"(
[
"anon",
"/home/anon",

View file

@ -7,8 +7,8 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/String.h>
TEST_CASE(relative_path)
{

View file

@ -6,9 +6,9 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/MemMem.h>
#include <AK/Memory.h>
#include <AK/String.h>
TEST_CASE(bitap)
{
@ -78,9 +78,9 @@ TEST_CASE(kmp_two_chunks)
TEST_CASE(timing_safe_compare)
{
String data_set = "abcdefghijklmnopqrstuvwxyz123456789";
DeprecatedString data_set = "abcdefghijklmnopqrstuvwxyz123456789";
EXPECT_EQ(true, AK::timing_safe_compare(data_set.characters(), data_set.characters(), data_set.length()));
String reversed = data_set.reverse();
DeprecatedString reversed = data_set.reverse();
EXPECT_EQ(false, AK::timing_safe_compare(data_set.characters(), reversed.characters(), reversed.length()));
}

View file

@ -6,8 +6,8 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
struct Object : public RefCounted<Object> {
int x;

View file

@ -7,8 +7,8 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Vector.h>
TEST_CASE(basic_optional)
@ -59,7 +59,7 @@ TEST_CASE(optional_rvalue_ref_qualified_getters)
TEST_CASE(optional_leak_1)
{
struct Structure {
Optional<String> str;
Optional<DeprecatedString> str;
};
// This used to leak, it does not anymore.
@ -81,7 +81,7 @@ TEST_CASE(comparison_without_values)
{
Optional<StringView> opt0;
Optional<StringView> opt1;
Optional<String> opt2;
Optional<DeprecatedString> opt2;
EXPECT_EQ(opt0, opt1);
EXPECT_EQ(opt0, opt2);
}
@ -90,7 +90,7 @@ TEST_CASE(comparison_with_values)
{
Optional<StringView> opt0;
Optional<StringView> opt1 = "foo"sv;
Optional<String> opt2 = "foo"sv;
Optional<DeprecatedString> opt2 = "foo"sv;
Optional<StringView> opt3 = "bar"sv;
EXPECT_NE(opt0, opt1);
EXPECT_EQ(opt1, opt2);
@ -99,14 +99,14 @@ TEST_CASE(comparison_with_values)
TEST_CASE(comparison_to_underlying_types)
{
Optional<String> opt0;
EXPECT_NE(opt0, String());
Optional<DeprecatedString> opt0;
EXPECT_NE(opt0, DeprecatedString());
EXPECT_NE(opt0, "foo");
Optional<StringView> opt1 = "foo"sv;
EXPECT_EQ(opt1, "foo");
EXPECT_NE(opt1, "bar");
EXPECT_EQ(opt1, String("foo"));
EXPECT_EQ(opt1, DeprecatedString("foo"));
}
TEST_CASE(comparison_with_numeric_types)
@ -262,7 +262,7 @@ TEST_CASE(comparison_reference)
StringView test = "foo"sv;
Optional<StringView&> opt0;
Optional<StringView const&> opt1 = test;
Optional<String> opt2 = "foo"sv;
Optional<DeprecatedString> opt2 = "foo"sv;
Optional<StringView> opt3 = "bar"sv;
EXPECT_NE(opt0, opt1);

View file

@ -6,8 +6,8 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/Queue.h>
#include <AK/String.h>
TEST_CASE(construct)
{
@ -32,7 +32,7 @@ TEST_CASE(populate_int)
TEST_CASE(populate_string)
{
Queue<String> strings;
Queue<DeprecatedString> strings;
strings.enqueue("ABC");
strings.enqueue("DEF");
EXPECT_EQ(strings.size(), 2u);
@ -43,11 +43,11 @@ TEST_CASE(populate_string)
TEST_CASE(order)
{
Queue<String> strings;
Queue<DeprecatedString> strings;
EXPECT(strings.is_empty());
for (size_t i = 0; i < 10000; ++i) {
strings.enqueue(String::number(i));
strings.enqueue(DeprecatedString::number(i));
EXPECT_EQ(strings.size(), i + 1);
}

View file

@ -6,8 +6,8 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
struct Object : public RefCounted<Object> {
int x;

View file

@ -26,7 +26,7 @@ TEST_CASE(basic)
TEST_CASE(complex_type)
{
AK::Stack<String, 4> stack;
AK::Stack<DeprecatedString, 4> stack;
EXPECT_EQ(stack.is_empty(), true);
EXPECT(stack.push("Well"));

View file

@ -282,7 +282,7 @@ TEST_CASE(convert_to_uint_from_octal)
TEST_CASE(ends_with)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
EXPECT(AK::StringUtils::ends_with(test_string, "DEF"sv, CaseSensitivity::CaseSensitive));
EXPECT(AK::StringUtils::ends_with(test_string, "ABCDEF"sv, CaseSensitivity::CaseSensitive));
EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDE"sv, CaseSensitivity::CaseSensitive));
@ -293,7 +293,7 @@ TEST_CASE(ends_with)
TEST_CASE(starts_with)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
EXPECT(AK::StringUtils::starts_with(test_string, "ABC"sv, CaseSensitivity::CaseSensitive));
EXPECT(AK::StringUtils::starts_with(test_string, "ABCDEF"sv, CaseSensitivity::CaseSensitive));
EXPECT(!AK::StringUtils::starts_with(test_string, "BCDEF"sv, CaseSensitivity::CaseSensitive));
@ -304,7 +304,7 @@ TEST_CASE(starts_with)
TEST_CASE(contains)
{
String test_string = "ABCDEFABCXYZ";
DeprecatedString test_string = "ABCDEFABCXYZ";
EXPECT(AK::StringUtils::contains(test_string, "ABC"sv, CaseSensitivity::CaseSensitive));
EXPECT(AK::StringUtils::contains(test_string, "ABC"sv, CaseSensitivity::CaseInsensitive));
EXPECT(AK::StringUtils::contains(test_string, "AbC"sv, CaseSensitivity::CaseInsensitive));
@ -322,7 +322,7 @@ TEST_CASE(contains)
EXPECT(!AK::StringUtils::contains(test_string, "L"sv, CaseSensitivity::CaseSensitive));
EXPECT(!AK::StringUtils::contains(test_string, "L"sv, CaseSensitivity::CaseInsensitive));
String command_palette_bug_string = "Go Go Back";
DeprecatedString command_palette_bug_string = "Go Go Back";
EXPECT(AK::StringUtils::contains(command_palette_bug_string, "Go Back"sv, AK::CaseSensitivity::CaseSensitive));
EXPECT(AK::StringUtils::contains(command_palette_bug_string, "gO bAcK"sv, AK::CaseSensitivity::CaseInsensitive));
}
@ -351,7 +351,7 @@ TEST_CASE(trim)
TEST_CASE(find)
{
String test_string = "1234567";
DeprecatedString test_string = "1234567";
EXPECT_EQ(AK::StringUtils::find(test_string, "1"sv).value_or(1), 0u);
EXPECT_EQ(AK::StringUtils::find(test_string, "2"sv).value_or(2), 1u);
EXPECT_EQ(AK::StringUtils::find(test_string, "3"sv).value_or(3), 2u);

View file

@ -6,7 +6,7 @@
#include <LibTest/TestCase.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Vector.h>
TEST_CASE(construct_empty)
@ -29,8 +29,8 @@ TEST_CASE(view_literal)
TEST_CASE(compare_views)
{
String foo1 = "foo";
String foo2 = "foo";
DeprecatedString foo1 = "foo";
DeprecatedString foo2 = "foo";
auto view1 = foo1.view();
auto view2 = foo2.view();
@ -43,7 +43,7 @@ TEST_CASE(compare_views)
TEST_CASE(string_view_literal_operator)
{
StringView literal_view = "foo"sv;
String test_string = "foo";
DeprecatedString test_string = "foo";
EXPECT_EQ(literal_view.length(), test_string.length());
EXPECT_EQ(literal_view, test_string);
@ -51,7 +51,7 @@ TEST_CASE(string_view_literal_operator)
TEST_CASE(starts_with)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
StringView test_string_view = test_string.view();
EXPECT(test_string_view.starts_with('A'));
EXPECT(!test_string_view.starts_with('B'));
@ -64,7 +64,7 @@ TEST_CASE(starts_with)
TEST_CASE(ends_with)
{
String test_string = "ABCDEF";
DeprecatedString test_string = "ABCDEF";
StringView test_string_view = test_string.view();
EXPECT(test_string_view.ends_with("DEF"sv));
EXPECT(test_string_view.ends_with('F'));
@ -78,23 +78,23 @@ TEST_CASE(ends_with)
TEST_CASE(lines)
{
String test_string = "a\rb\nc\r\nd";
DeprecatedString test_string = "a\rb\nc\r\nd";
StringView test_string_view = test_string.view();
Vector<StringView> test_string_vector = test_string_view.lines();
EXPECT_EQ(test_string_vector.size(), 4u);
EXPECT(test_string_vector.at(0) == String("a"));
EXPECT(test_string_vector.at(1) == String("b"));
EXPECT(test_string_vector.at(2) == String("c"));
EXPECT(test_string_vector.at(3) == String("d"));
EXPECT(test_string_vector.at(0) == DeprecatedString("a"));
EXPECT(test_string_vector.at(1) == DeprecatedString("b"));
EXPECT(test_string_vector.at(2) == DeprecatedString("c"));
EXPECT(test_string_vector.at(3) == DeprecatedString("d"));
test_string = "```\nHello there\r\nHello there\n```";
test_string_view = test_string.view();
test_string_vector = test_string_view.lines();
EXPECT_EQ(test_string_vector.size(), 4u);
EXPECT(test_string_vector.at(0) == String("```"));
EXPECT(test_string_vector.at(1) == String("Hello there"));
EXPECT(test_string_vector.at(2) == String("Hello there"));
EXPECT(test_string_vector.at(3) == String("```"));
EXPECT(test_string_vector.at(0) == DeprecatedString("```"));
EXPECT(test_string_vector.at(1) == DeprecatedString("Hello there"));
EXPECT(test_string_vector.at(2) == DeprecatedString("Hello there"));
EXPECT(test_string_vector.at(3) == DeprecatedString("```"));
test_string = "\n\n\n";
test_string_view = test_string.view();

View file

@ -11,12 +11,12 @@
TEST_CASE(normal_behavior)
{
Trie<char, String> dictionary('/', "");
Trie<char, DeprecatedString> dictionary('/', "");
constexpr StringView data[] { "test"sv, "example"sv, "foo"sv, "foobar"sv };
constexpr size_t total_chars = 18; // root (1), 'test' (4), 'example' (7), 'foo' (3), 'foobar' (3, "foo" already stored).
for (auto& view : data) {
auto it = view.begin();
MUST(dictionary.insert(it, view.end(), view, [](auto& parent, auto& it) -> Optional<String> { return String::formatted("{}{}", parent.metadata_value(), *it); }));
MUST(dictionary.insert(it, view.end(), view, [](auto& parent, auto& it) -> Optional<DeprecatedString> { return DeprecatedString::formatted("{}{}", parent.metadata_value(), *it); }));
}
size_t i = 0;

View file

@ -10,41 +10,41 @@
TEST_CASE(basic)
{
Tuple<int, String> value { 1, "foo" };
Tuple<int, DeprecatedString> value { 1, "foo" };
EXPECT_EQ(value.get<int>(), 1);
EXPECT_EQ(value.get<String>(), "foo");
EXPECT_EQ(value.get<DeprecatedString>(), "foo");
EXPECT_EQ(value.get<0>(), 1);
EXPECT_EQ(value.get<1>(), "foo");
// Move assignment
value = { 2, "bar" };
EXPECT_EQ(value.get<int>(), 2);
EXPECT_EQ(value.get<String>(), "bar");
EXPECT_EQ(value.get<DeprecatedString>(), "bar");
EXPECT_EQ(value.get<0>(), 2);
EXPECT_EQ(value.get<1>(), "bar");
// Copy ctor
auto other_value { value };
EXPECT_EQ(other_value.get<int>(), 2);
EXPECT_EQ(other_value.get<String>(), "bar");
EXPECT_EQ(other_value.get<DeprecatedString>(), "bar");
EXPECT_EQ(other_value.get<0>(), 2);
EXPECT_EQ(other_value.get<1>(), "bar");
// Move ctor
auto moved_to_value { move(value) };
EXPECT_EQ(moved_to_value.get<int>(), 2);
EXPECT_EQ(moved_to_value.get<String>(), "bar");
EXPECT_EQ(moved_to_value.get<DeprecatedString>(), "bar");
EXPECT_EQ(moved_to_value.get<0>(), 2);
EXPECT_EQ(moved_to_value.get<1>(), "bar");
// Copy assignment
value = moved_to_value;
EXPECT_EQ(moved_to_value.get<int>(), 2);
EXPECT_EQ(moved_to_value.get<String>(), "bar");
EXPECT_EQ(moved_to_value.get<DeprecatedString>(), "bar");
EXPECT_EQ(moved_to_value.get<0>(), 2);
EXPECT_EQ(moved_to_value.get<1>(), "bar");
EXPECT_EQ(value.get<int>(), 2);
EXPECT_EQ(value.get<String>(), "bar");
EXPECT_EQ(value.get<DeprecatedString>(), "bar");
EXPECT_EQ(value.get<0>(), 2);
EXPECT_EQ(value.get<1>(), "bar");
}
@ -68,12 +68,12 @@ TEST_CASE(no_copy)
TEST_CASE(apply)
{
Tuple<int, int, String> args { 1, 2, "foo" };
Tuple<int, int, DeprecatedString> args { 1, 2, "foo" };
// With copy
{
bool was_called = false;
args.apply_as_args([&](int a, int b, String c) {
args.apply_as_args([&](int a, int b, DeprecatedString c) {
was_called = true;
EXPECT_EQ(a, 1);
EXPECT_EQ(b, 2);
@ -85,7 +85,7 @@ TEST_CASE(apply)
// With reference
{
bool was_called = false;
args.apply_as_args([&](int& a, int& b, String& c) {
args.apply_as_args([&](int& a, int& b, DeprecatedString& c) {
was_called = true;
EXPECT_EQ(a, 1);
EXPECT_EQ(b, 2);
@ -98,7 +98,7 @@ TEST_CASE(apply)
{
bool was_called = false;
auto const& args_ref = args;
args_ref.apply_as_args([&](int const& a, int const& b, String const& c) {
args_ref.apply_as_args([&](int const& a, int const& b, DeprecatedString const& c) {
was_called = true;
EXPECT_EQ(a, 1);
EXPECT_EQ(b, 2);

View file

@ -7,7 +7,7 @@
#include <LibTest/TestCase.h>
#include <AK/Array.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <AK/Types.h>
#include <AK/Utf16View.h>
@ -53,7 +53,7 @@ TEST_CASE(decode_utf8)
TEST_CASE(encode_utf8)
{
{
String utf8_string("Привет, мир! 😀 γειά σου κόσμος こんにちは世界");
DeprecatedString utf8_string("Привет, мир! 😀 γειά σου κόσμος こんにちは世界");
auto string = AK::utf8_to_utf16(utf8_string);
Utf16View view { string };
EXPECT_EQ(view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes), utf8_string);

View file

@ -34,7 +34,7 @@ TEST_CASE(decode_utf8)
EXPECT(valid_bytes == (size_t)utf8.byte_length());
u32 expected[] = { 1055, 1088, 1080, 1074, 1077, 1090, 44, 32, 1084, 1080, 1088, 33, 32, 128512, 32, 947, 949, 953, 940, 32, 963, 959, 965, 32, 954, 972, 963, 956, 959, 962, 32, 12371, 12435, 12395, 12385, 12399, 19990, 30028 };
String expected_underlying_bytes[] = { "П", "р", "и", "в", "е", "т", ",", " ", "м", "и", "р", "!", " ", "😀", " ", "γ", "ε", "ι", "ά", " ", "σ", "ο", "υ", " ", "κ", "ό", "σ", "μ", "ο", "ς", " ", "", "", "", "", "", "", "" };
DeprecatedString expected_underlying_bytes[] = { "П", "р", "и", "в", "е", "т", ",", " ", "м", "и", "р", "!", " ", "😀", " ", "γ", "ε", "ι", "ά", " ", "σ", "ο", "υ", " ", "κ", "ό", "σ", "μ", "ο", "ς", " ", "", "", "", "", "", "", "" };
size_t expected_size = sizeof(expected) / sizeof(expected[0]);
size_t i = 0;
@ -125,7 +125,7 @@ TEST_CASE(decode_invalid_ut8)
char raw_data[] = { 'a', 'b', (char)0xA0, 'd' };
Utf8View view { StringView { raw_data, 4 } };
u32 expected_characters[] = { 'a', 'b', 0xFFFD, 'd' };
String expected_underlying_bytes[] = { "a", "b", "\xA0", "d" };
DeprecatedString expected_underlying_bytes[] = { "a", "b", "\xA0", "d" };
size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]);
size_t i = 0;
for (auto it = view.begin(); it != view.end(); ++it) {
@ -143,7 +143,7 @@ TEST_CASE(decode_invalid_ut8)
char raw_data[] = { 'a', 'b', (char)0xC0, 'd', 'e' };
Utf8View view { StringView { raw_data, 5 } };
u32 expected_characters[] = { 'a', 'b', 0xFFFD, 'd', 'e' };
String expected_underlying_bytes[] = { "a", "b", "\xC0", "d", "e" };
DeprecatedString expected_underlying_bytes[] = { "a", "b", "\xC0", "d", "e" };
size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]);
size_t i = 0;
for (auto it = view.begin(); it != view.end(); ++it) {
@ -161,7 +161,7 @@ TEST_CASE(decode_invalid_ut8)
char raw_data[] = { 'a', 'b', (char)0x90, 'd' };
Utf8View view { StringView { raw_data, 4 } };
u32 expected_characters[] = { 'a', 'b', 0xFFFD, 'd' };
String expected_underlying_bytes[] = { "a", "b", "\x90", "d" };
DeprecatedString expected_underlying_bytes[] = { "a", "b", "\x90", "d" };
size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]);
size_t i = 0;
for (auto it = view.begin(); it != view.end(); ++it) {
@ -179,7 +179,7 @@ TEST_CASE(decode_invalid_ut8)
char raw_data[] = { 'a', 'b', 'c', (char)0x90 };
Utf8View view { StringView { raw_data, 4 } };
u32 expected_characters[] = { 'a', 'b', 'c', 0xFFFD };
String expected_underlying_bytes[] = { "a", "b", "c", "\x90" };
DeprecatedString expected_underlying_bytes[] = { "a", "b", "c", "\x90" };
size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]);
size_t i = 0;
for (auto it = view.begin(); it != view.end(); ++it) {
@ -206,7 +206,7 @@ TEST_CASE(decode_invalid_ut8)
// https://www.unicode.org/versions/Unicode14.0.0/ch03.pdf , section "U+FFFD Substitution of Maximal Subparts"
// However, that would go against how we deal with several other kinds of errors, so we stick to emitting only one U+FFFD.
u32 expected_characters[] = { 'a', 0xFFFD, 'b' };
String expected_underlying_bytes[] = { "a", "\xF4\xA3\x91\x96", "b" };
DeprecatedString expected_underlying_bytes[] = { "a", "\xF4\xA3\x91\x96", "b" };
size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]);
size_t i = 0;
for (auto it = view.begin(); it != view.end(); ++it) {

View file

@ -18,21 +18,21 @@ struct Object : public RefCounted<Object> {
TEST_CASE(basic)
{
Variant<int, String> the_value { 42 };
Variant<int, DeprecatedString> the_value { 42 };
EXPECT(the_value.has<int>());
EXPECT_EQ(the_value.get<int>(), 42);
the_value = String("42");
EXPECT(the_value.has<String>());
EXPECT_EQ(the_value.get<String>(), "42");
the_value = DeprecatedString("42");
EXPECT(the_value.has<DeprecatedString>());
EXPECT_EQ(the_value.get<DeprecatedString>(), "42");
}
TEST_CASE(visit)
{
bool correct = false;
Variant<int, String, float> the_value { 42.0f };
Variant<int, DeprecatedString, float> the_value { 42.0f };
the_value.visit(
[&](int const&) { correct = false; },
[&](String const&) { correct = false; },
[&](DeprecatedString const&) { correct = false; },
[&](float const&) { correct = true; });
EXPECT(correct);
}
@ -40,10 +40,10 @@ TEST_CASE(visit)
TEST_CASE(visit_const)
{
bool correct = false;
Variant<int, String> const the_value { "42"sv };
Variant<int, DeprecatedString> const the_value { "42"sv };
the_value.visit(
[&](String const&) { correct = true; },
[&](DeprecatedString const&) { correct = true; },
[&](auto&) {},
[&](auto const&) {});
@ -52,7 +52,7 @@ TEST_CASE(visit_const)
correct = false;
auto the_value_but_not_const = the_value;
the_value_but_not_const.visit(
[&](String const&) { correct = true; },
[&](DeprecatedString const&) { correct = true; },
[&](auto&) {});
EXPECT(correct);
@ -168,13 +168,13 @@ TEST_CASE(duplicated_types)
TEST_CASE(return_values)
{
using MyVariant = Variant<int, String, float>;
using MyVariant = Variant<int, DeprecatedString, float>;
{
MyVariant the_value { 42.0f };
float value = the_value.visit(
[&](int const&) { return 1.0f; },
[&](String const&) { return 2.0f; },
[&](DeprecatedString const&) { return 2.0f; },
[&](float const& f) { return f; });
EXPECT_EQ(value, 42.0f);
}
@ -183,17 +183,17 @@ TEST_CASE(return_values)
int value = the_value.visit(
[&](int& i) { return i; },
[&](String&) { return 2; },
[&](DeprecatedString&) { return 2; },
[&](float&) { return 3; });
EXPECT_EQ(value, 42);
}
{
const MyVariant the_value { "str" };
String value = the_value.visit(
[&](int const&) { return String { "wrong" }; },
[&](String const& s) { return s; },
[&](float const&) { return String { "wrong" }; });
DeprecatedString value = the_value.visit(
[&](int const&) { return DeprecatedString { "wrong" }; },
[&](DeprecatedString const& s) { return s; },
[&](float const&) { return DeprecatedString { "wrong" }; });
EXPECT_EQ(value, "str");
}
}
@ -201,11 +201,11 @@ TEST_CASE(return_values)
TEST_CASE(return_values_by_reference)
{
auto ref = adopt_ref_if_nonnull(new (nothrow) Object());
Variant<int, String, float> the_value { 42.0f };
Variant<int, DeprecatedString, float> the_value { 42.0f };
auto& value = the_value.visit(
[&](int const&) -> RefPtr<Object>& { return ref; },
[&](String const&) -> RefPtr<Object>& { return ref; },
[&](DeprecatedString const&) -> RefPtr<Object>& { return ref; },
[&](float const&) -> RefPtr<Object>& { return ref; });
EXPECT_EQ(ref, value);
@ -223,7 +223,7 @@ struct HoldsFloat {
TEST_CASE(copy_assign)
{
{
Variant<int, String, float> the_value { 42.0f };
Variant<int, DeprecatedString, float> the_value { 42.0f };
VERIFY(the_value.has<float>());
EXPECT_EQ(the_value.get<float>(), 42.0f);
@ -233,12 +233,12 @@ TEST_CASE(copy_assign)
VERIFY(the_value.has<int>());
EXPECT_EQ(the_value.get<int>(), 12);
the_value = String("Hello, world!");
VERIFY(the_value.has<String>());
EXPECT_EQ(the_value.get<String>(), "Hello, world!");
the_value = DeprecatedString("Hello, world!");
VERIFY(the_value.has<DeprecatedString>());
EXPECT_EQ(the_value.get<DeprecatedString>(), "Hello, world!");
}
{
Variant<HoldsInt, String, HoldsFloat> the_value { HoldsFloat { 42.0f } };
Variant<HoldsInt, DeprecatedString, HoldsFloat> the_value { HoldsFloat { 42.0f } };
VERIFY(the_value.has<HoldsFloat>());
EXPECT_EQ(the_value.get<HoldsFloat>().f, 42.0f);
@ -248,9 +248,9 @@ TEST_CASE(copy_assign)
VERIFY(the_value.has<HoldsInt>());
EXPECT_EQ(the_value.get<HoldsInt>().i, 12);
the_value = String("Hello, world!");
VERIFY(the_value.has<String>());
EXPECT_EQ(the_value.get<String>(), "Hello, world!");
the_value = DeprecatedString("Hello, world!");
VERIFY(the_value.has<DeprecatedString>());
EXPECT_EQ(the_value.get<DeprecatedString>(), "Hello, world!");
}
}

View file

@ -7,9 +7,9 @@
#include "AK/ReverseIterator.h"
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/OwnPtr.h>
#include <AK/String.h>
#include <AK/Vector.h>
TEST_CASE(construct)
@ -38,19 +38,19 @@ TEST_CASE(ints)
TEST_CASE(strings)
{
Vector<String> strings;
Vector<DeprecatedString> strings;
strings.append("ABC");
strings.append("DEF");
int loop_counter = 0;
for (String const& string : strings) {
for (DeprecatedString const& string : strings) {
EXPECT(!string.is_null());
EXPECT(!string.is_empty());
++loop_counter;
}
loop_counter = 0;
for (auto& string : (const_cast<Vector<String> const&>(strings))) {
for (auto& string : (const_cast<Vector<DeprecatedString> const&>(strings))) {
EXPECT(!string.is_null());
EXPECT(!string.is_empty());
++loop_counter;
@ -60,7 +60,7 @@ TEST_CASE(strings)
TEST_CASE(strings_insert_ordered)
{
Vector<String> strings;
Vector<DeprecatedString> strings;
strings.append("abc");
strings.append("def");
strings.append("ghi");
@ -163,12 +163,12 @@ TEST_CASE(vector_compare)
EXPECT_EQ(ints.size(), 1000u);
EXPECT_EQ(ints, same_ints);
Vector<String> strings;
Vector<String> same_strings;
Vector<DeprecatedString> strings;
Vector<DeprecatedString> same_strings;
for (int i = 0; i < 1000; ++i) {
strings.append(String::number(i));
same_strings.append(String::number(i));
strings.append(DeprecatedString::number(i));
same_strings.append(DeprecatedString::number(i));
}
EXPECT_EQ(strings.size(), 1000u);
@ -178,9 +178,9 @@ TEST_CASE(vector_compare)
TEST_CASE(grow_past_inline_capacity)
{
auto make_vector = [] {
Vector<String, 16> strings;
Vector<DeprecatedString, 16> strings;
for (int i = 0; i < 32; ++i) {
strings.append(String::number(i));
strings.append(DeprecatedString::number(i));
}
return strings;
};
@ -286,7 +286,7 @@ TEST_CASE(remove_all_matching)
TEST_CASE(nonnullownptrvector)
{
struct Object {
String string;
DeprecatedString string;
};
NonnullOwnPtrVector<Object> objects;

View file

@ -6,7 +6,7 @@
#include <LibTest/TestCase.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/WeakPtr.h>
#include <AK/Weakable.h>

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibCore/File.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
@ -81,12 +81,12 @@ TEST_CASE(test_change_file_location)
ftruncate(fd, 0);
EXPECT(fchmod(fd, 06755) != -1);
auto suid_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto suid_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!suid_path_or_error.is_error());
auto suid_path = suid_path_or_error.release_value();
EXPECT(suid_path.characters());
auto new_path = String::formatted("{}.renamed", suid_path);
auto new_path = DeprecatedString::formatted("{}.renamed", suid_path);
rename(suid_path.characters(), new_path.characters());

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibTest/TestCase.h>
#include <errno.h>
#include <unistd.h>
@ -18,7 +18,7 @@ TEST_CASE(test_nonexistent_pledge)
TEST_CASE(test_pledge_argument_validation)
{
auto const long_argument = String::repeated('a', 2048);
auto const long_argument = DeprecatedString::repeated('a', 2048);
auto res = pledge(long_argument.characters(), "stdio");
EXPECT_EQ(res, -1);

View file

@ -6,8 +6,8 @@
*/
#include <AK/Assertions.h>
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/String.h>
#if ARCH(I386) || ARCH(X86_64)
# include <Kernel/Arch/x86/IO.h>
#endif

View file

@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/Random.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <Kernel/API/SyscallString.h>

View file

@ -14,7 +14,7 @@
struct FlacTest : Test::TestCase {
FlacTest(LexicalPath path)
: Test::TestCase(
String::formatted("flac_spec_test_{}", path.basename()), [this]() { run(); }, false)
DeprecatedString::formatted("flac_spec_test_{}", path.basename()), [this]() { run(); }, false)
, m_path(std::move(path))
{
}
@ -23,7 +23,7 @@ struct FlacTest : Test::TestCase {
{
auto result = Audio::FlacLoaderPlugin::try_create(m_path.string());
if (result.is_error()) {
FAIL(String::formatted("{} (at {})", result.error().description, result.error().index));
FAIL(DeprecatedString::formatted("{} (at {})", result.error().description, result.error().index));
return;
}
@ -32,7 +32,7 @@ struct FlacTest : Test::TestCase {
while (true) {
auto maybe_samples = loader->get_more_samples(2 * MiB);
if (maybe_samples.is_error()) {
FAIL(String::formatted("{} (at {})", maybe_samples.error().description, maybe_samples.error().index));
FAIL(DeprecatedString::formatted("{} (at {})", maybe_samples.error().description, maybe_samples.error().index));
return;
}
if (maybe_samples.value().is_empty())

View file

@ -24,12 +24,12 @@ static int read_event(int fd)
return rc;
}
static String get_event_name()
static DeprecatedString get_event_name()
{
if (event->name_length == 0)
return String();
return DeprecatedString();
return String { event->name, event->name_length - 1 };
return DeprecatedString { event->name, event->name_length - 1 };
}
TEST_CASE(inode_watcher_metadata_modified_event)

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibCore/File.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
@ -23,7 +23,7 @@ TEST_CASE(test_mktemp_unique_filename)
if (fork() == 0) {
char path[] = "/tmp/test.mktemp.XXXXXX";
auto temp_path = String::formatted("{}", mktemp(path));
auto temp_path = DeprecatedString::formatted("{}", mktemp(path));
EXPECT(temp_path.characters());
unlink(path);
@ -33,10 +33,10 @@ TEST_CASE(test_mktemp_unique_filename)
} else {
wait(NULL);
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mktemp.XXXXXX";
auto path2 = String::formatted("{}", mktemp(path));
auto path2 = DeprecatedString::formatted("{}", mktemp(path));
EXPECT(path2.characters());
unlink(path);
@ -53,7 +53,7 @@ TEST_CASE(test_mkdtemp_unique_filename)
if (fork() == 0) {
char path[] = "/tmp/test.mkdtemp.XXXXXX";
auto temp_path = String::formatted("{}", mkdtemp(path));
auto temp_path = DeprecatedString::formatted("{}", mkdtemp(path));
EXPECT(temp_path.characters());
rmdir(path);
@ -63,10 +63,10 @@ TEST_CASE(test_mkdtemp_unique_filename)
} else {
wait(NULL);
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mkdtemp.XXXXXX";
auto path2 = String::formatted("{}", mkdtemp(path));
auto path2 = DeprecatedString::formatted("{}", mkdtemp(path));
EXPECT(path2.characters());
rmdir(path);
@ -86,7 +86,7 @@ TEST_CASE(test_mkstemp_unique_filename)
auto fd = mkstemp(path);
EXPECT_NE(fd, -1);
auto temp_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto temp_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!temp_path_or_error.is_error());
auto temp_path = temp_path_or_error.release_value();
@ -101,13 +101,13 @@ TEST_CASE(test_mkstemp_unique_filename)
} else {
wait(NULL);
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mkstemp.XXXXXX";
auto fd = mkstemp(path);
EXPECT(fd != -1);
auto path2_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto path2_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!path2_or_error.is_error());
auto path2 = path2_or_error.release_value();
@ -132,7 +132,7 @@ TEST_CASE(test_mkstemps_unique_filename)
auto fd = mkstemps(path, 6);
EXPECT_NE(fd, -1);
auto temp_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto temp_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!temp_path_or_error.is_error());
auto temp_path = temp_path_or_error.release_value();
@ -151,13 +151,13 @@ TEST_CASE(test_mkstemps_unique_filename)
} else {
wait(NULL);
auto path1 = String::formatted("{}", reinterpret_cast<char const*>(ptr));
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
char path[] = "/tmp/test.mkstemps.prefixXXXXXXsuffix";
auto fd = mkstemps(path, 6);
EXPECT(fd != -1);
auto path2_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto path2_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!path2_or_error.is_error());
auto path2 = path2_or_error.release_value();

View file

@ -37,7 +37,7 @@ TEST_CASE(memmem_search)
auto expected = test_case.matching_offset >= 0 ? test_case.haystack + test_case.matching_offset : nullptr;
auto result = memmem(test_case.haystack, test_case.haystack_length, test_case.needle, test_case.needle_length);
if (result != expected) {
FAIL(String::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result));
FAIL(DeprecatedString::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result));
}
++i;
}

View file

@ -12,9 +12,9 @@
#include <time.h>
#include <unistd.h>
static String random_dirname()
static DeprecatedString random_dirname()
{
return String::formatted("/tmp/test_mkdir_{:04x}", (u16)rand());
return DeprecatedString::formatted("/tmp/test_mkdir_{:04x}", (u16)rand());
}
TEST_SETUP
@ -46,7 +46,7 @@ TEST_CASE(insufficient_permissions)
TEST_CASE(nonexistent_parent)
{
auto parent = random_dirname();
auto child = String::formatted("{}/foo", parent);
auto child = DeprecatedString::formatted("{}/foo", parent);
int res = mkdir(child.characters(), 0755);
int cached_errno = errno;
EXPECT(res < 0);

View file

@ -10,7 +10,7 @@
#include <pwd.h>
struct PasswdEntry {
String name;
DeprecatedString name;
uid_t uid {};
};

View file

@ -6,9 +6,9 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/QuickSort.h>
#include <AK/Random.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <stdlib.h>
@ -63,7 +63,7 @@ TEST_CASE(quick_sort)
auto const& key1 = test_objects[i].m_key;
auto const& key2 = test_objects[i + 1].m_key;
if (key1 > key2) {
FAIL(String::formatted("saw key {} before key {}\n", key1, key2));
FAIL(DeprecatedString::formatted("saw key {} before key {}\n", key1, key2));
}
}
// Check that the object's payloads have not been corrupted
@ -71,7 +71,7 @@ TEST_CASE(quick_sort)
auto const expected = calc_payload_for_pos(i);
auto const payload = test_objects[i].m_payload;
if (payload != expected) {
FAIL(String::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload));
FAIL(DeprecatedString::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload));
}
}
}

View file

@ -6,7 +6,7 @@
#include <LibTest/TestCase.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <errno.h>
#include <limits.h>
@ -21,10 +21,10 @@ static constexpr char PATH_LOREM_250[] = "This-is-an-annoyingly-long-name-that-s
static constexpr size_t ITERATION_DEPTH = 17;
static void check_result(char const* what, String const& expected, char const* actual)
static void check_result(char const* what, DeprecatedString const& expected, char const* actual)
{
if (expected != actual)
FAIL(String::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0));
FAIL(DeprecatedString::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0));
}
TEST_CASE(overlong_realpath)
@ -59,7 +59,7 @@ TEST_CASE(overlong_realpath)
ret = mkdir(PATH_LOREM_250, S_IRWXU);
if (ret < 0) {
perror("mkdir iter");
FAIL(String::formatted("Unable to mkdir the overlong path fragment in iteration {}", i));
FAIL(DeprecatedString::formatted("Unable to mkdir the overlong path fragment in iteration {}", i));
return;
}
expected.append('/');
@ -67,7 +67,7 @@ TEST_CASE(overlong_realpath)
ret = chdir(PATH_LOREM_250);
if (ret < 0) {
perror("chdir iter");
FAIL(String::formatted("Unable to chdir to the overlong path fragment in iteration {}", i));
FAIL(DeprecatedString::formatted("Unable to chdir to the overlong path fragment in iteration {}", i));
return;
}
}

View file

@ -166,7 +166,7 @@ void twalk_action(void const* node, VISIT order, int depth)
// Special case: End signaled by tester.
if (depth == TWALK_CHECK_END) {
if (tests[count].depth != TWALK_END_MARKER) {
FAIL(String::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.",
FAIL(DeprecatedString::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.",
tests[count].node, U8(tests[count].order), tests[count].depth));
}
return;
@ -174,7 +174,7 @@ void twalk_action(void const* node, VISIT order, int depth)
// Special case: End marker reached.
if (tests[count].depth == TWALK_END_MARKER) {
FAIL(String::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).",
FAIL(DeprecatedString::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).",
node, U8(order), depth));
return;
}

View file

@ -28,7 +28,7 @@ struct Testcase {
size_t dest_expected_n; // == dest_n
};
static String show(ByteBuffer const& buf)
static DeprecatedString show(ByteBuffer const& buf)
{
StringBuilder builder;
for (size_t i = 0; i < buf.size(); ++i) {

View file

@ -22,7 +22,7 @@ struct Testcase {
size_t dest_expected_n; // == dest_n
};
static String show(ByteBuffer const& buf)
static DeprecatedString show(ByteBuffer const& buf)
{
StringBuilder builder;
for (size_t i = 0; i < buf.size(); ++i) {

View file

@ -7,8 +7,8 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/String.h>
#include <stdlib.h>
#include <string.h>
@ -330,7 +330,7 @@ static long long hex_to_ll(char const* hex)
} else if ('a' <= ch && ch <= 'f') {
digit = ch - 'a' + 10;
} else {
FAIL(String::formatted("\n!!! Encountered char {:02x} at {}", ch, i));
FAIL(DeprecatedString::formatted("\n!!! Encountered char {:02x} at {}", ch, i));
return result;
}
result <<= 4;
@ -366,7 +366,7 @@ TEST_CASE(strtod_accuracy)
}
outln("Out of {} tests, saw {} successes and {} fails.", NUM_TESTCASES, successes, fails);
if (fails != 0) {
FAIL(String::formatted("{} strtod tests failed", fails));
FAIL(DeprecatedString::formatted("{} strtod tests failed", fails));
}
outln("PASS (with leniency up to {} ULP from the exact solution)", LENIENCY);

View file

@ -215,7 +215,7 @@ TEST_CASE(mbsinit)
size_t ret = mbrtowc(nullptr, "\xdf", 1, &state);
if (ret != -2ul)
FAIL(String::formatted("mbrtowc accepted partial multibyte sequence with return code {} (expected -2)", static_cast<ssize_t>(ret)));
FAIL(DeprecatedString::formatted("mbrtowc accepted partial multibyte sequence with return code {} (expected -2)", static_cast<ssize_t>(ret)));
// Ensure that we are not in an initial state.
EXPECT(mbsinit(&state) == 0);
@ -224,7 +224,7 @@ TEST_CASE(mbsinit)
ret = mbrtowc(nullptr, "\xbf", 1, &state);
if (ret != 1ul)
FAIL(String::formatted("mbrtowc did not consume the expected number of bytes (1), returned {} instead", static_cast<ssize_t>(ret)));
FAIL(DeprecatedString::formatted("mbrtowc did not consume the expected number of bytes (1), returned {} instead", static_cast<ssize_t>(ret)));
// Ensure that we are in an initial state again.
EXPECT(mbsinit(&state) != 0);

View file

@ -13,15 +13,15 @@ static void run_test(StringView const file_name)
{
// This makes sure that the tests will run both on target and in Lagom.
#ifdef AK_OS_SERENITY
String path = String::formatted("/usr/Tests/LibCompress/brotli-test-files/{}", file_name);
DeprecatedString path = DeprecatedString::formatted("/usr/Tests/LibCompress/brotli-test-files/{}", file_name);
#else
String path = String::formatted("brotli-test-files/{}", file_name);
DeprecatedString path = DeprecatedString::formatted("brotli-test-files/{}", file_name);
#endif
auto cmp_file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
auto cmp_data = MUST(cmp_file->read_all());
String path_compressed = String::formatted("{}.br", path);
DeprecatedString path_compressed = DeprecatedString::formatted("{}.br", path);
auto file = MUST(Core::Stream::File::open(path_compressed, Core::Stream::OpenMode::Read));
auto brotli_stream = Compress::BrotliDecompressionStream { *file };
@ -89,12 +89,12 @@ TEST_CASE(brotli_decompress_zero_one_bin)
{
// This makes sure that the tests will run both on target and in Lagom.
#ifdef AK_OS_SERENITY
String path = "/usr/Tests/LibCompress/brotli-test-files/zero-one.bin";
DeprecatedString path = "/usr/Tests/LibCompress/brotli-test-files/zero-one.bin";
#else
String path = "brotli-test-files/zero-one.bin";
DeprecatedString path = "brotli-test-files/zero-one.bin";
#endif
String path_compressed = String::formatted("{}.br", path);
DeprecatedString path_compressed = DeprecatedString::formatted("{}.br", path);
auto file = MUST(Core::Stream::File::open(path_compressed, Core::Stream::OpenMode::Read));
auto brotli_stream = Compress::BrotliDecompressionStream { *file };

View file

@ -12,7 +12,7 @@
class ParserResult {
public:
ParserResult(Vector<String> const& arguments)
ParserResult(Vector<DeprecatedString> const& arguments)
{
argv = new char*[arguments.size() + 1];
argc = 0;
@ -60,7 +60,7 @@ public:
size_t argc { 0 };
};
static ParserResult run_parser(Vector<String> arguments, Function<void(Core::ArgsParser&)> parser_initialization = {})
static ParserResult run_parser(Vector<DeprecatedString> arguments, Function<void(Core::ArgsParser&)> parser_initialization = {})
{
Core::ArgsParser parser;
if (parser_initialization)
@ -139,7 +139,7 @@ TEST_CASE(bool_option)
TEST_CASE(positional_string_argument)
{
// Single required string argument
String name = "";
DeprecatedString name = "";
auto parser_result = run_parser({ "app", "buggie" }, [&](auto& parser) {
parser.add_positional_argument(name, "name", "name", Core::ArgsParser::Required::Yes);
});

View file

@ -8,7 +8,7 @@
#include <LibTest/TestCase.h>
#include <unistd.h>
static bool files_have_same_contents(String filename1, String filename2)
static bool files_have_same_contents(DeprecatedString filename1, DeprecatedString filename2)
{
auto file1 = Core::File::open(filename1, Core::OpenMode::ReadOnly).value();
auto file2 = Core::File::open(filename2, Core::OpenMode::ReadOnly).value();
@ -40,7 +40,7 @@ TEST_CASE(file_readline)
TEST_CASE(file_get_read_position)
{
const String path = "10kb.txt";
const DeprecatedString path = "10kb.txt";
auto file = Core::File::open(path, Core::OpenMode::ReadOnly).release_value();
const size_t step_size = 98;

View file

@ -13,14 +13,14 @@
constexpr char TESTS_ROOT_DIR[] = "/home/anon/Tests/cpp-tests/parser";
static String read_all(String const& path)
static DeprecatedString read_all(DeprecatedString const& path)
{
auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
auto file_size = MUST(file->size());
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
if (!file->read_or_error(content.bytes()))
VERIFY_NOT_REACHED();
return String { content.bytes() };
return DeprecatedString { content.bytes() };
}
TEST_CASE(test_regression)
@ -36,7 +36,7 @@ TEST_CASE(test_regression)
outln("Checking {}...", path.basename());
auto ast_file_path = String::formatted("{}.ast", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1));
auto ast_file_path = DeprecatedString::formatted("{}.ast", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1));
auto source = read_all(file_path);
auto target_ast = read_all(ast_file_path);
@ -72,7 +72,7 @@ TEST_CASE(test_regression)
fclose(input_stream);
String content { reinterpret_cast<char const*>(buffer.data()), buffer.size() };
DeprecatedString content { reinterpret_cast<char const*>(buffer.data()), buffer.size() };
auto equal = content == target_ast;
EXPECT(equal);

View file

@ -12,14 +12,14 @@
constexpr char TESTS_ROOT_DIR[] = "/home/anon/Tests/cpp-tests/preprocessor";
static String read_all(String const& path)
static DeprecatedString read_all(DeprecatedString const& path)
{
auto file = MUST(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
auto file_size = MUST(file->size());
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
if (!file->read_or_error(content.bytes()))
VERIFY_NOT_REACHED();
return String { content.bytes() };
return DeprecatedString { content.bytes() };
}
TEST_CASE(test_regression)
@ -35,7 +35,7 @@ TEST_CASE(test_regression)
outln("Checking {}...", path.basename());
auto ast_file_path = String::formatted("{}.txt", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1));
auto ast_file_path = DeprecatedString::formatted("{}.txt", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1));
auto source = read_all(file_path);
auto target = read_all(ast_file_path);

View file

@ -15,11 +15,11 @@ TEST_CASE(test_adler32)
EXPECT_EQ(digest, expected_result);
};
do_test(String("").bytes(), 0x1);
do_test(String("a").bytes(), 0x00620062);
do_test(String("abc").bytes(), 0x024d0127);
do_test(String("message digest").bytes(), 0x29750586);
do_test(String("abcdefghijklmnopqrstuvwxyz").bytes(), 0x90860b20);
do_test(DeprecatedString("").bytes(), 0x1);
do_test(DeprecatedString("a").bytes(), 0x00620062);
do_test(DeprecatedString("abc").bytes(), 0x024d0127);
do_test(DeprecatedString("message digest").bytes(), 0x29750586);
do_test(DeprecatedString("abcdefghijklmnopqrstuvwxyz").bytes(), 0x90860b20);
}
TEST_CASE(test_crc32)
@ -29,7 +29,7 @@ TEST_CASE(test_crc32)
EXPECT_EQ(digest, expected_result);
};
do_test(String("").bytes(), 0x0);
do_test(String("The quick brown fox jumps over the lazy dog").bytes(), 0x414FA339);
do_test(String("various CRC algorithms input data").bytes(), 0x9BD366AE);
do_test(DeprecatedString("").bytes(), 0x0);
do_test(DeprecatedString("The quick brown fox jumps over the lazy dog").bytes(), 0x414FA339);
do_test(DeprecatedString("various CRC algorithms input data").bytes(), 0x9BD366AE);
}

View file

@ -58,7 +58,7 @@ TEST_CASE(test_interp_header_tiny_p_filesz)
int nwritten = write(fd, buffer, sizeof(buffer));
EXPECT(nwritten);
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();
@ -115,7 +115,7 @@ TEST_CASE(test_interp_header_p_filesz_larger_than_p_memsz)
int nwritten = write(fd, buffer, sizeof(buffer));
EXPECT(nwritten);
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();
@ -176,7 +176,7 @@ TEST_CASE(test_interp_header_p_filesz_plus_p_offset_overflow_p_memsz)
int nwritten = write(fd, buffer, sizeof(buffer));
EXPECT(nwritten);
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();
@ -234,7 +234,7 @@ TEST_CASE(test_load_header_p_memsz_zero)
int nwritten = write(fd, buffer, sizeof(buffer));
EXPECT(nwritten);
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();
@ -292,7 +292,7 @@ TEST_CASE(test_load_header_p_memsz_not_equal_to_p_align)
int nwritten = write(fd, buffer, sizeof(buffer));
EXPECT(nwritten);
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = Core::File::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();

View file

@ -5,8 +5,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/String.h>
#include <LibCore/FileStream.h>
#include <LibGL/GL/gl.h>
#include <LibGL/GLContext.h>
@ -31,7 +31,7 @@ static NonnullOwnPtr<GL::GLContext> create_testing_context(int width, int height
static void expect_bitmap_equals_reference(Gfx::Bitmap const& bitmap, StringView test_name)
{
auto reference_filename = String::formatted("{}.qoi", test_name);
auto reference_filename = DeprecatedString::formatted("{}.qoi", test_name);
if constexpr (SAVE_OUTPUT) {
auto target_path = LexicalPath("/home/anon").append(reference_filename);
@ -42,7 +42,7 @@ static void expect_bitmap_equals_reference(Gfx::Bitmap const& bitmap, StringView
EXPECT_EQ(number_of_bytes_written, qoi_buffer.size());
}
auto reference_image_path = String::formatted(REFERENCE_IMAGE_DIR "/{}", reference_filename);
auto reference_image_path = DeprecatedString::formatted(REFERENCE_IMAGE_DIR "/{}", reference_filename);
auto reference_bitmap = MUST(Gfx::Bitmap::try_load_from_file(reference_image_path));
EXPECT_EQ(reference_bitmap->visually_equals(bitmap), true);
}

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibCore/MappedFile.h>
#include <LibGfx/BMPLoader.h>
#include <LibGfx/GIFLoader.h>

View file

@ -69,7 +69,7 @@ TESTJS_GLOBAL_FUNCTION(mark_as_garbage, markAsGarbage)
auto value = TRY(reference.get_value(vm));
if (!can_be_held_weakly(value))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::CannotBeHeldWeakly, String::formatted("Variable with name {}", variable_name.string()));
return vm.throw_completion<JS::TypeError>(JS::ErrorType::CannotBeHeldWeakly, DeprecatedString::formatted("Variable with name {}", variable_name.string()));
vm.heap().uproot_cell(&value.as_cell());
TRY(reference.delete_(vm));
@ -88,7 +88,7 @@ TESTJS_GLOBAL_FUNCTION(detach_array_buffer, detachArrayBuffer)
return JS::js_null();
}
TESTJS_RUN_FILE_FUNCTION(String const& test_file, JS::Interpreter& interpreter, JS::ExecutionContext&)
TESTJS_RUN_FILE_FUNCTION(DeprecatedString const& test_file, JS::Interpreter& interpreter, JS::ExecutionContext&)
{
if (!test262_parser_tests)
return Test::JS::RunFileHookResult::RunAsNormal;
@ -123,8 +123,8 @@ TESTJS_RUN_FILE_FUNCTION(String const& test_file, JS::Interpreter& interpreter,
parse_succeeded = !Test::JS::parse_script(test_file, interpreter.realm()).is_error();
bool test_passed = true;
String message;
String expectation_string;
DeprecatedString message;
DeprecatedString expectation_string;
switch (expectation) {
case Early:

View file

@ -4,13 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/HashMap.h>
#include <AK/JsonObject.h>
#include <AK/JsonParser.h>
#include <AK/LexicalPath.h>
#include <AK/QuickSort.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
@ -147,7 +147,7 @@ public:
{
}
bool write_lines(Span<String> lines)
bool write_lines(Span<DeprecatedString> lines)
{
// It's possible the process dies before we can write all the tests
// to the stdin. So make sure that we don't crash but just stop writing.
@ -160,8 +160,8 @@ public:
return false;
}
for (String const& line : lines) {
if (!m_output->write_or_error(String::formatted("{}\n", line).bytes()))
for (DeprecatedString const& line : lines) {
if (!m_output->write_or_error(DeprecatedString::formatted("{}\n", line).bytes()))
break;
}
@ -175,14 +175,14 @@ public:
return true;
}
String read_all()
DeprecatedString read_all()
{
auto all_output_or_error = m_input->read_all();
if (all_output_or_error.is_error()) {
warnln("Got error: {} while reading runner output", all_output_or_error.error());
return ""sv;
}
return String(all_output_or_error.value().bytes(), Chomp);
return DeprecatedString(all_output_or_error.value().bytes(), Chomp);
}
enum class ProcessResult {
@ -222,7 +222,7 @@ public:
NonnullOwnPtr<Core::Stream::File> m_output;
};
static HashMap<size_t, TestResult> run_test_files(Span<String> files, size_t offset, StringView command, char const* const arguments[])
static HashMap<size_t, TestResult> run_test_files(Span<DeprecatedString> files, size_t offset, StringView command, char const* const arguments[])
{
HashMap<size_t, TestResult> results {};
results.ensure_capacity(files.size());
@ -246,7 +246,7 @@ static HashMap<size_t, TestResult> run_test_files(Span<String> files, size_t off
return results;
}
String output = runner_process->read_all();
DeprecatedString output = runner_process->read_all();
auto status_or_error = runner_process->status();
bool failed = false;
if (!status_or_error.is_error()) {
@ -297,7 +297,7 @@ static HashMap<size_t, TestResult> run_test_files(Span<String> files, size_t off
return results;
}
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<String> const& paths, StringView per_file_name, double time_taken_in_ms);
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<DeprecatedString> const& paths, StringView per_file_name, double time_taken_in_ms);
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
@ -320,12 +320,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.parse(arguments);
// Normalize the path to ensure filenames are consistent
Vector<String> paths;
Vector<DeprecatedString> paths;
if (!Core::File::is_directory(test_directory)) {
paths.append(test_directory);
} else {
Test::iterate_directory_recursively(LexicalPath::canonicalized_path(test_directory), [&](String const& file_path) {
Test::iterate_directory_recursively(LexicalPath::canonicalized_path(test_directory), [&](DeprecatedString const& file_path) {
if (file_path.contains("_FIXTURE"sv))
return;
// FIXME: Add ignored file set
@ -337,7 +337,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
outln("Found {} tests", paths.size());
auto parameters = pass_through_parameters.split_view(' ');
Vector<String> args;
Vector<DeprecatedString> args;
args.ensure_capacity(parameters.size() + 2);
args.append(runner_command);
if (!dont_disable_core_dump)
@ -408,7 +408,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
}
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<String> const& paths, StringView per_file_name, double time_taken_in_ms)
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<DeprecatedString> const& paths, StringView per_file_name, double time_taken_in_ms)
{
auto file_or_error = Core::Stream::File::open(per_file_name, Core::Stream::OpenMode::Write);

View file

@ -5,11 +5,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/JsonObject.h>
#include <AK/Result.h>
#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/Stream.h>
@ -31,11 +31,11 @@
# include <sys/prctl.h>
#endif
static String s_current_test = "";
static DeprecatedString s_current_test = "";
static bool s_use_bytecode = false;
static bool s_enable_bytecode_optimizations = false;
static bool s_parse_only = false;
static String s_harness_file_directory;
static DeprecatedString s_harness_file_directory;
static bool s_automatic_harness_detection_mode = false;
enum class NegativePhase {
@ -47,9 +47,9 @@ enum class NegativePhase {
struct TestError {
NegativePhase phase { NegativePhase::ParseOrEarly };
String type;
String details;
String harness_file;
DeprecatedString type;
DeprecatedString details;
DeprecatedString harness_file;
};
using ScriptOrModuleProgram = Variant<JS::NonnullGCPtr<JS::Script>, JS::NonnullGCPtr<JS::SourceTextModule>>;
@ -93,7 +93,7 @@ static Result<void, TestError> run_program(InterpreterT& interpreter, ScriptOrMo
auto unit_result = JS::Bytecode::Generator::generate(program_node);
if (unit_result.is_error()) {
result = JS::throw_completion(JS::InternalError::create(interpreter.realm(), String::formatted("TODO({})", unit_result.error().to_string())));
result = JS::throw_completion(JS::InternalError::create(interpreter.realm(), DeprecatedString::formatted("TODO({})", unit_result.error().to_string())));
} else {
auto unit = unit_result.release_value();
auto optimization_level = s_enable_bytecode_optimizations ? JS::Bytecode::Interpreter::OptimizationLevel::Optimize : JS::Bytecode::Interpreter::OptimizationLevel::Default;
@ -133,18 +133,18 @@ static Result<void, TestError> run_program(InterpreterT& interpreter, ScriptOrMo
return {};
}
static HashMap<String, String> s_cached_harness_files;
static HashMap<DeprecatedString, DeprecatedString> s_cached_harness_files;
static Result<StringView, TestError> read_harness_file(StringView harness_file)
{
auto cache = s_cached_harness_files.find(harness_file);
if (cache == s_cached_harness_files.end()) {
auto file_or_error = Core::Stream::File::open(String::formatted("{}{}", s_harness_file_directory, harness_file), Core::Stream::OpenMode::Read);
auto file_or_error = Core::Stream::File::open(DeprecatedString::formatted("{}{}", s_harness_file_directory, harness_file), Core::Stream::OpenMode::Read);
if (file_or_error.is_error()) {
return TestError {
NegativePhase::Harness,
"filesystem",
String::formatted("Could not open file: {}", harness_file),
DeprecatedString::formatted("Could not open file: {}", harness_file),
harness_file
};
}
@ -154,7 +154,7 @@ static Result<StringView, TestError> read_harness_file(StringView harness_file)
return TestError {
NegativePhase::Harness,
"filesystem",
String::formatted("Could not read file: {}", harness_file),
DeprecatedString::formatted("Could not read file: {}", harness_file),
harness_file
};
}
@ -264,14 +264,14 @@ static Result<void, TestError> run_test(StringView source, StringView filepath,
return run_with_interpreter(program_or_error.value());
}
static Result<TestMetadata, String> extract_metadata(StringView source)
static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source)
{
auto lines = source.lines();
TestMetadata metadata;
bool parsing_negative = false;
String failed_message;
DeprecatedString failed_message;
auto parse_list = [&](StringView line) {
auto start = line.find('[');
@ -282,7 +282,7 @@ static Result<TestMetadata, String> extract_metadata(StringView source)
auto end = line.find_last(']');
if (!end.has_value() || end.value() <= start.value()) {
failed_message = String::formatted("Can't parse list in '{}'", line);
failed_message = DeprecatedString::formatted("Can't parse list in '{}'", line);
return items;
}
@ -295,7 +295,7 @@ static Result<TestMetadata, String> extract_metadata(StringView source)
auto second_word = [&](StringView line) {
auto separator = line.find(' ');
if (!separator.has_value() || separator.value() >= (line.length() - 1u)) {
failed_message = String::formatted("Can't parse value after space in '{}'", line);
failed_message = DeprecatedString::formatted("Can't parse value after space in '{}'", line);
return ""sv;
}
return line.substring_view(separator.value() + 1);
@ -349,7 +349,7 @@ static Result<TestMetadata, String> extract_metadata(StringView source)
metadata.phase = NegativePhase::Runtime;
} else {
has_phase = false;
failed_message = String::formatted("Unknown negative phase: {}", phase);
failed_message = DeprecatedString::formatted("Unknown negative phase: {}", phase);
break;
}
} else if (line.starts_with("type:"sv)) {
@ -372,7 +372,7 @@ static Result<TestMetadata, String> extract_metadata(StringView source)
auto flags = parse_list(line);
if (flags.is_empty()) {
failed_message = String::formatted("Failed to find flags in '{}'", line);
failed_message = DeprecatedString::formatted("Failed to find flags in '{}'", line);
break;
}
@ -408,7 +408,7 @@ static Result<TestMetadata, String> extract_metadata(StringView source)
}
if (failed_message.is_empty())
failed_message = String::formatted("Never reached end of comment '---*/'");
failed_message = DeprecatedString::formatted("Never reached end of comment '---*/'");
return failed_message;
}
@ -522,7 +522,7 @@ static bool verify_test(Result<void, TestError>& result, TestMetadata const& met
return error.phase == metadata.phase && error.type == metadata.type;
}
static bool extract_harness_directory(String const& test_file_path)
static bool extract_harness_directory(DeprecatedString const& test_file_path)
{
auto test_directory_index = test_file_path.find("test/"sv);
if (!test_directory_index.has_value()) {
@ -530,7 +530,7 @@ static bool extract_harness_directory(String const& test_file_path)
return false;
}
s_harness_file_directory = String::formatted("{}harness/", test_file_path.substring_view(0, test_directory_index.value()));
s_harness_file_directory = DeprecatedString::formatted("{}harness/", test_file_path.substring_view(0, test_directory_index.value()));
return true;
}
@ -568,7 +568,7 @@ extern "C" __attribute__((__noreturn__)) void __assert_fail(char const* assertio
extern "C" __attribute__((__noreturn__)) void __assert_fail(char const* assertion, char const* file, unsigned int line, char const* function)
# endif
{
auto full_message = String::formatted("{}:{}: {}: Assertion `{}' failed.", file, line, function, assertion);
auto full_message = DeprecatedString::formatted("{}:{}: {}: Assertion `{}' failed.", file, line, function, assertion);
handle_failed_assert(full_message.characters());
}
#endif
@ -605,7 +605,7 @@ int main(int argc, char** argv)
if (s_harness_file_directory.is_empty()) {
s_automatic_harness_detection_mode = true;
} else if (!s_harness_file_directory.ends_with('/')) {
s_harness_file_directory = String::formatted("{}/", s_harness_file_directory);
s_harness_file_directory = DeprecatedString::formatted("{}/", s_harness_file_directory);
}
if (timeout <= 0) {
@ -658,10 +658,10 @@ int main(int argc, char** argv)
auto collect_output = [&] {
fflush(stdout);
auto nread = read(stdout_pipe[0], buffer, BUFFER_SIZE);
String value;
DeprecatedString value;
if (nread > 0) {
value = String { buffer, static_cast<size_t>(nread) };
value = DeprecatedString { buffer, static_cast<size_t>(nread) };
while (nread > 0) {
nread = read(stdout_pipe[0], buffer, BUFFER_SIZE);
}
@ -714,7 +714,7 @@ int main(int argc, char** argv)
count++;
String source_with_strict;
DeprecatedString source_with_strict;
static StringView use_strict = "'use strict';\n"sv;
static size_t strict_length = use_strict.length();
@ -761,7 +761,7 @@ int main(int argc, char** argv)
auto result = run_test(original_contents, path, metadata);
DISARM_TIMER();
String first_output = collect_output();
DeprecatedString first_output = collect_output();
if (!first_output.is_null())
result_object.set("output", first_output);
@ -784,7 +784,7 @@ int main(int argc, char** argv)
auto result = run_test(with_strict, path, metadata);
DISARM_TIMER();
String first_output = collect_output();
DeprecatedString first_output = collect_output();
if (!first_output.is_null())
result_object.set("strict_output", first_output);

View file

@ -93,7 +93,7 @@ TEST_CASE(parse_unicode_locale_id)
auto locale_id = Locale::parse_unicode_locale_id(locale);
EXPECT(!locale_id.has_value());
};
auto pass = [](StringView locale, Optional<StringView> expected_language, Optional<StringView> expected_script, Optional<StringView> expected_region, Vector<String> expected_variants) {
auto pass = [](StringView locale, Optional<StringView> expected_language, Optional<StringView> expected_script, Optional<StringView> expected_region, Vector<DeprecatedString> expected_variants) {
auto locale_id = Locale::parse_unicode_locale_id(locale);
VERIFY(locale_id.has_value());
@ -270,7 +270,7 @@ TEST_CASE(parse_unicode_locale_id_with_private_use_extension)
auto locale_id = Locale::parse_unicode_locale_id(locale);
EXPECT(!locale_id.has_value());
};
auto pass = [](StringView locale, Vector<String> const& expected_extension) {
auto pass = [](StringView locale, Vector<DeprecatedString> const& expected_extension) {
auto locale_id = Locale::parse_unicode_locale_id(locale);
VERIFY(locale_id.has_value());
EXPECT_EQ(locale_id->private_use_extensions, expected_extension);

View file

@ -4,10 +4,10 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
#include <AK/JsonParser.h>
#include <AK/String.h>
#include <LibCore/Stream.h>
#include <LibMarkdown/Document.h>
#include <LibTest/TestCase.h>
@ -24,20 +24,20 @@ TEST_SETUP
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
if (!file->read_or_error(content.bytes()))
VERIFY_NOT_REACHED();
String test_data { content.bytes() };
DeprecatedString test_data { content.bytes() };
auto tests = JsonParser(test_data).parse().value().as_array();
for (size_t i = 0; i < tests.size(); ++i) {
auto testcase = tests[i].as_object();
auto name = String::formatted("{}_ex{}_{}..{}",
auto name = DeprecatedString::formatted("{}_ex{}_{}..{}",
testcase.get("section"sv),
testcase.get("example"sv),
testcase.get("start_line"sv),
testcase.get("end_line"sv));
String markdown = testcase.get("markdown"sv).as_string();
String html = testcase.get("html"sv).as_string();
DeprecatedString markdown = testcase.get("markdown"sv).as_string();
DeprecatedString html = testcase.get("html"sv).as_string();
Test::TestSuite::the().add_case(adopt_ref(*new Test::TestCase(
name, [markdown, html]() {

View file

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/Forward.h>
#include <AK/String.h>
#include <LibCore/MappedFile.h>
#include <LibPDF/Document.h>
#include <LibTest/Macros.h>
@ -47,7 +47,7 @@ TEST_CASE(empty_file_issue_10702)
TEST_CASE(truncated_pdf_header_issue_10717)
{
AK::String string { "%PDF-2.11%" };
AK::DeprecatedString string { "%PDF-2.11%" };
auto document = PDF::Document::create(string.bytes());
EXPECT(document.is_error());
}

View file

@ -121,7 +121,7 @@ TEST_CASE(regex_lexer)
TEST_CASE(parser_error_parens)
{
String pattern = "test()test";
DeprecatedString pattern = "test()test";
Lexer l(pattern);
PosixExtendedParser p(l);
p.parse();
@ -131,7 +131,7 @@ TEST_CASE(parser_error_parens)
TEST_CASE(parser_error_special_characters_used_at_wrong_place)
{
String pattern;
DeprecatedString pattern;
Vector<char, 5> chars = { '*', '+', '?', '{' };
StringBuilder b;
@ -266,7 +266,7 @@ TEST_CASE(catch_all_newline)
Regex<PosixExtended> re("^.*$", PosixFlags::Multiline | PosixFlags::StringCopyMatches);
RegexResult result;
auto lambda = [&result, &re]() {
String aaa = "Hello World\nTest\n1234\n";
DeprecatedString aaa = "Hello World\nTest\n1234\n";
result = match(aaa, re);
EXPECT_EQ(result.success, true);
};
@ -282,11 +282,11 @@ TEST_CASE(catch_all_newline_view)
Regex<PosixExtended> re("^.*$", PosixFlags::Multiline);
RegexResult result;
String aaa = "Hello World\nTest\n1234\n";
DeprecatedString aaa = "Hello World\nTest\n1234\n";
result = match(aaa, re);
EXPECT_EQ(result.success, true);
EXPECT_EQ(result.count, 3u);
String str = "Hello World";
DeprecatedString str = "Hello World";
EXPECT_EQ(result.matches.at(0).view, str.view());
EXPECT_EQ(result.matches.at(1).view, "Test");
EXPECT_EQ(result.matches.at(2).view, "1234");
@ -312,7 +312,7 @@ TEST_CASE(catch_all_newline_2)
TEST_CASE(match_all_character_class)
{
Regex<PosixExtended> re("[[:alpha:]]");
String str = "[Window]\nOpacity=255\nAudibleBeep=0\n";
DeprecatedString str = "[Window]\nOpacity=255\nAudibleBeep=0\n";
RegexResult result = match(str, re, PosixFlags::Global | PosixFlags::StringCopyMatches);
EXPECT_EQ(result.success, true);
@ -325,7 +325,7 @@ TEST_CASE(match_all_character_class)
TEST_CASE(match_character_class_with_assertion)
{
Regex<PosixExtended> re("[[:alpha:]]+$");
String str = "abcdef";
DeprecatedString str = "abcdef";
RegexResult result = match(str, re);
EXPECT_EQ(result.success, true);
@ -371,7 +371,7 @@ TEST_CASE(ini_file_entries)
regex_dbg.print_bytecode(re);
}
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true);
EXPECT_EQ(result.count, 3u);
@ -399,7 +399,7 @@ TEST_CASE(ini_file_entries2)
Regex<PosixExtended> re("[[:alpha:]]*=([[:digit:]]*)");
RegexResult result;
String haystack = "ViewMode=Icon";
DeprecatedString haystack = "ViewMode=Icon";
EXPECT_EQ(re.match(haystack.view(), result), false);
EXPECT_EQ(result.count, 0u);
@ -420,7 +420,7 @@ TEST_CASE(named_capture_group)
regex_dbg.print_bytecode(re);
}
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
EXPECT_EQ(re.search(haystack, result, PosixFlags::Multiline), true);
EXPECT_EQ(result.count, 2u);
EXPECT_EQ(result.matches.at(0).view, "Opacity=255");
@ -443,7 +443,7 @@ TEST_CASE(ecma262_named_capture_group_with_dollar_sign)
regex_dbg.print_bytecode(re);
}
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
EXPECT_EQ(re.search(haystack, result, ECMAScriptFlags::Multiline), true);
EXPECT_EQ(result.count, 2u);
EXPECT_EQ(result.matches.at(0).view, "Opacity=255");
@ -466,7 +466,7 @@ TEST_CASE(a_star)
regex_dbg.print_bytecode(re);
}
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true);
EXPECT_EQ(result.count, 32u);
if (result.count == 32u) {
@ -499,7 +499,7 @@ TEST_CASE(posix_extended_nested_capture_group)
EXPECT_EQ(result.capture_group_matches[0][2].view, "llo"sv);
}
auto parse_test_case_long_disjunction_chain = String::repeated("a|"sv, 100000);
auto parse_test_case_long_disjunction_chain = DeprecatedString::repeated("a|"sv, 100000);
TEST_CASE(ECMA262_parse)
{
@ -931,7 +931,7 @@ TEST_CASE(case_insensitive_match)
TEST_CASE(extremely_long_fork_chain)
{
Regex<ECMA262> re("(?:aa)*");
auto result = re.match(String::repeated('a', 1000));
auto result = re.match(DeprecatedString::repeated('a', 1000));
EXPECT_EQ(result.success, true);
}
@ -950,7 +950,7 @@ TEST_CASE(theoretically_infinite_loop)
}
}
static auto g_lots_of_a_s = String::repeated('a', 10'000'000);
static auto g_lots_of_a_s = DeprecatedString::repeated('a', 10'000'000);
BENCHMARK_CASE(fork_performance)
{

View file

@ -13,7 +13,7 @@
TEST_CASE(catch_all)
{
String pattern = "^.*$";
DeprecatedString pattern = "^.*$";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -24,7 +24,7 @@ TEST_CASE(catch_all)
TEST_CASE(simple_start)
{
String pattern = "^hello friends";
DeprecatedString pattern = "^hello friends";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -37,7 +37,7 @@ TEST_CASE(simple_start)
TEST_CASE(simple_end)
{
String pattern = ".*hello\\.\\.\\. there$";
DeprecatedString pattern = ".*hello\\.\\.\\. there$";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -51,7 +51,7 @@ TEST_CASE(simple_end)
TEST_CASE(simple_period)
{
String pattern = "hello.";
DeprecatedString pattern = "hello.";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -65,7 +65,7 @@ TEST_CASE(simple_period)
TEST_CASE(simple_period_end)
{
String pattern = "hello.$";
DeprecatedString pattern = "hello.$";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED | REG_NOSUB), REG_NOERR);
@ -79,7 +79,7 @@ TEST_CASE(simple_period_end)
TEST_CASE(simple_escaped)
{
String pattern = "hello\\.";
DeprecatedString pattern = "hello\\.";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -91,7 +91,7 @@ TEST_CASE(simple_escaped)
TEST_CASE(simple_period2_end)
{
String pattern = ".*hi... there$";
DeprecatedString pattern = ".*hi... there$";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -106,7 +106,7 @@ TEST_CASE(simple_period2_end)
TEST_CASE(simple_plus)
{
String pattern = "a+";
DeprecatedString pattern = "a+";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED | REG_NOSUB), REG_NOERR);
@ -120,7 +120,7 @@ TEST_CASE(simple_plus)
TEST_CASE(simple_questionmark)
{
String pattern = "da?d";
DeprecatedString pattern = "da?d";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -137,7 +137,7 @@ TEST_CASE(simple_questionmark)
TEST_CASE(simple_questionmark_matchall)
{
String pattern = "da?d";
DeprecatedString pattern = "da?d";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -170,12 +170,12 @@ TEST_CASE(simple_questionmark_matchall)
TEST_CASE(character_class)
{
String pattern = "[[:alpha:]]";
DeprecatedString pattern = "[[:alpha:]]";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
EXPECT_EQ(regexec(&regex, haystack.characters(), num_matches, matches, 0), REG_NOMATCH);
EXPECT_EQ(matches[0].rm_cnt, 0);
@ -189,12 +189,12 @@ TEST_CASE(character_class)
TEST_CASE(character_class2)
{
String pattern = "[[:alpha:]]*=([[:digit:]]*)|\\[(.*)\\]";
DeprecatedString pattern = "[[:alpha:]]*=([[:digit:]]*)|\\[(.*)\\]";
regex_t regex;
static constexpr int num_matches { 9 };
regmatch_t matches[num_matches];
String haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED | REG_NEWLINE), REG_NOERR);
EXPECT_EQ(regexec(&regex, haystack.characters(), num_matches, matches, 0), REG_NOERR);
@ -235,7 +235,7 @@ TEST_CASE(character_class2)
TEST_CASE(escaped_char_questionmark)
{
String pattern = "This\\.?And\\.?That";
DeprecatedString pattern = "This\\.?And\\.?That";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -249,7 +249,7 @@ TEST_CASE(escaped_char_questionmark)
TEST_CASE(char_qualifier_asterisk)
{
String pattern = "regex*";
DeprecatedString pattern = "regex*";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -263,7 +263,7 @@ TEST_CASE(char_qualifier_asterisk)
TEST_CASE(char_utf8)
{
String pattern = "😀";
DeprecatedString pattern = "😀";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -277,7 +277,7 @@ TEST_CASE(char_utf8)
TEST_CASE(parens)
{
String pattern = "test(hello)test";
DeprecatedString pattern = "test(hello)test";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -297,7 +297,7 @@ TEST_CASE(parens)
TEST_CASE(parser_error_parens)
{
String pattern = "test()test";
DeprecatedString pattern = "test()test";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -310,7 +310,7 @@ TEST_CASE(parser_error_parens)
TEST_CASE(parser_error_special_characters_used_at_wrong_place)
{
String pattern;
DeprecatedString pattern;
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -371,7 +371,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
TEST_CASE(parser_error_vertical_line_used_at_wrong_place)
{
String pattern;
DeprecatedString pattern;
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -403,7 +403,7 @@ TEST_CASE(parser_error_vertical_line_used_at_wrong_place)
TEST_CASE(parens_qualifier_questionmark)
{
String pattern = "test(hello)?test";
DeprecatedString pattern = "test(hello)?test";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -433,7 +433,7 @@ TEST_CASE(parens_qualifier_questionmark)
TEST_CASE(parens_qualifier_asterisk)
{
String pattern = "test(hello)*test";
DeprecatedString pattern = "test(hello)*test";
regex_t regex;
static constexpr int num_matches { 6 };
regmatch_t matches[num_matches];
@ -479,7 +479,7 @@ TEST_CASE(parens_qualifier_asterisk)
TEST_CASE(parens_qualifier_asterisk_2)
{
String pattern = "test(.*)test";
DeprecatedString pattern = "test(.*)test";
regex_t regex;
static constexpr int num_matches { 6 };
regmatch_t matches[num_matches];
@ -523,7 +523,7 @@ TEST_CASE(parens_qualifier_asterisk_2)
TEST_CASE(mulit_parens_qualifier_too_less_result_values)
{
String pattern = "test(a)?(b)?(c)?test";
DeprecatedString pattern = "test(a)?(b)?(c)?test";
regex_t regex;
static constexpr int num_matches { 4 };
regmatch_t matches[num_matches];
@ -587,7 +587,7 @@ TEST_CASE(mulit_parens_qualifier_too_less_result_values)
TEST_CASE(multi_parens_qualifier_questionmark)
{
String pattern = "test(a)?(b)?(c)?test";
DeprecatedString pattern = "test(a)?(b)?(c)?test";
regex_t regex;
static constexpr int num_matches { 8 };
regmatch_t matches[num_matches];
@ -651,7 +651,7 @@ TEST_CASE(multi_parens_qualifier_questionmark)
TEST_CASE(simple_alternative)
{
String pattern = "test|hello|friends";
DeprecatedString pattern = "test|hello|friends";
regex_t regex;
static constexpr int num_matches { 1 };
regmatch_t matches[num_matches];
@ -678,7 +678,7 @@ TEST_CASE(simple_alternative)
TEST_CASE(alternative_match_groups)
{
String pattern = "test(a)?(b)?|hello ?(dear|my)? friends";
DeprecatedString pattern = "test(a)?(b)?|hello ?(dear|my)? friends";
regex_t regex;
static constexpr int num_matches { 8 };
regmatch_t matches[num_matches];
@ -784,7 +784,7 @@ TEST_CASE(alternative_match_groups)
TEST_CASE(parens_qualifier_exact)
{
String pattern = "(hello){3}";
DeprecatedString pattern = "(hello){3}";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -831,7 +831,7 @@ TEST_CASE(parens_qualifier_exact)
TEST_CASE(parens_qualifier_minimum)
{
String pattern = "(hello){3,}";
DeprecatedString pattern = "(hello){3,}";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -889,7 +889,7 @@ TEST_CASE(parens_qualifier_minimum)
TEST_CASE(parens_qualifier_maximum)
{
String pattern = "(hello){2,3}";
DeprecatedString pattern = "(hello){2,3}";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -946,7 +946,7 @@ TEST_CASE(parens_qualifier_maximum)
TEST_CASE(char_qualifier_min_max)
{
String pattern = "c{3,30}";
DeprecatedString pattern = "c{3,30}";
regex_t regex;
static constexpr int num_matches { 5 };
regmatch_t matches[num_matches];
@ -966,7 +966,7 @@ TEST_CASE(char_qualifier_min_max)
TEST_CASE(simple_bracket_chars)
{
String pattern = "[abc]";
DeprecatedString pattern = "[abc]";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -980,7 +980,7 @@ TEST_CASE(simple_bracket_chars)
TEST_CASE(simple_bracket_chars_inverse)
{
String pattern = "[^abc]";
DeprecatedString pattern = "[^abc]";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -994,7 +994,7 @@ TEST_CASE(simple_bracket_chars_inverse)
TEST_CASE(simple_bracket_chars_range)
{
String pattern = "[a-d]";
DeprecatedString pattern = "[a-d]";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -1008,7 +1008,7 @@ TEST_CASE(simple_bracket_chars_range)
TEST_CASE(simple_bracket_chars_range_inverse)
{
String pattern = "[^a-df-z]";
DeprecatedString pattern = "[^a-df-z]";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -1024,7 +1024,7 @@ TEST_CASE(simple_bracket_chars_range_inverse)
TEST_CASE(bracket_character_class_uuid)
{
String pattern = "^([[:xdigit:]]{8})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{12})$";
DeprecatedString pattern = "^([[:xdigit:]]{8})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{12})$";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -1036,7 +1036,7 @@ TEST_CASE(bracket_character_class_uuid)
TEST_CASE(simple_bracket_character_class_inverse)
{
String pattern = "[^[:digit:]]";
DeprecatedString pattern = "[^[:digit:]]";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -1050,7 +1050,7 @@ TEST_CASE(simple_bracket_character_class_inverse)
TEST_CASE(email_address)
{
String pattern = "^[A-Z0-9a-z._%+-]{1,64}@(?:[A-Za-z0-9-]{1,63}\\.){1,125}[A-Za-z]{2,63}$";
DeprecatedString pattern = "^[A-Z0-9a-z._%+-]{1,64}@(?:[A-Za-z0-9-]{1,63}\\.){1,125}[A-Za-z]{2,63}$";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_NOERR);
@ -1062,7 +1062,7 @@ TEST_CASE(email_address)
TEST_CASE(error_message)
{
String pattern = "^[A-Z0-9[a-z._%+-]{1,64}@[A-Za-z0-9-]{1,63}\\.{1,125}[A-Za-z]{2,63}$";
DeprecatedString pattern = "^[A-Z0-9[a-z._%+-]{1,64}@[A-Za-z0-9-]{1,63}\\.{1,125}[A-Za-z]{2,63}$";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED), REG_EBRACK);
@ -1070,7 +1070,7 @@ TEST_CASE(error_message)
char buf[1024];
size_t buflen = 1024;
auto len = regerror(0, &regex, buf, buflen);
String expected = "Error during parsing of regular expression:\n ^[A-Z0-9[a-z._%+-]{1,64}@[A-Za-z0-9-]{1,63}\\.{1,125}[A-Za-z]{2,63}$\n ^---- [ ] imbalance.";
DeprecatedString expected = "Error during parsing of regular expression:\n ^[A-Z0-9[a-z._%+-]{1,64}@[A-Za-z0-9-]{1,63}\\.{1,125}[A-Za-z]{2,63}$\n ^---- [ ] imbalance.";
for (size_t i = 0; i < len; ++i) {
EXPECT_EQ(buf[i], expected[i]);
}
@ -1080,7 +1080,7 @@ TEST_CASE(error_message)
TEST_CASE(simple_ignorecase)
{
String pattern = "^hello friends";
DeprecatedString pattern = "^hello friends";
regex_t regex;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED | REG_NOSUB | REG_ICASE), REG_NOERR);
@ -1098,8 +1098,8 @@ TEST_CASE(simple_ignorecase)
TEST_CASE(simple_notbol_noteol)
{
String pattern = "^hello friends$";
String pattern2 = "hello friends";
DeprecatedString pattern = "^hello friends$";
DeprecatedString pattern2 = "hello friends";
regex_t regex, regex2;
EXPECT_EQ(regcomp(&regex, pattern.characters(), REG_EXTENDED | REG_NOSUB | REG_ICASE), REG_NOERR);

View file

@ -7,9 +7,9 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/Result.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <AK/TypeCasts.h>
@ -31,7 +31,7 @@ public:
}
};
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Expression>, String>;
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Expression>, DeprecatedString>;
ParseResult parse(StringView sql)
{
@ -633,7 +633,7 @@ TEST_CASE(in_selection_expression)
TEST_CASE(expression_tree_depth_limit)
{
auto too_deep_expression = String::formatted("{:+^{}}1", "", SQL::AST::Limits::maximum_expression_tree_depth);
auto too_deep_expression = DeprecatedString::formatted("{:+^{}}1", "", SQL::AST::Limits::maximum_expression_tree_depth);
EXPECT(!parse(too_deep_expression.substring_view(1)).is_error());
EXPECT(parse(too_deep_expression).is_error());
}

View file

@ -148,7 +148,7 @@ void insert_and_get_to_and_from_hash_index(int num_keys)
for (auto ix = 0; ix < num_keys; ix++) {
SQL::Key k(hash_index->descriptor());
k[0] = keys[ix];
k[1] = String::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
k[1] = DeprecatedString::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
k.set_pointer(pointers[ix]);
hash_index->insert(k);
}
@ -166,7 +166,7 @@ void insert_and_get_to_and_from_hash_index(int num_keys)
for (auto ix = 0; ix < num_keys; ix++) {
SQL::Key k(hash_index->descriptor());
k[0] = keys[ix];
k[1] = String::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
k[1] = DeprecatedString::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
auto pointer_opt = hash_index->get(k);
VERIFY(pointer_opt.has_value());
EXPECT_EQ(pointer_opt.value(), pointers[ix]);
@ -246,7 +246,7 @@ void insert_into_and_scan_hash_index(int num_keys)
for (auto ix = 0; ix < num_keys; ix++) {
SQL::Key k(hash_index->descriptor());
k[0] = keys[ix];
k[1] = String::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
k[1] = DeprecatedString::formatted("The key value is {} and the pointer is {}", keys[ix], pointers[ix]);
k.set_pointer(pointers[ix]);
hash_index->insert(k);
}
@ -275,7 +275,7 @@ void insert_into_and_scan_hash_index(int num_keys)
if (keys[ix] == key_value) {
EXPECT_EQ(key.pointer(), pointers[ix]);
if (found[ix])
FAIL(String::formatted("Key {}, index {} already found previously", *key_value, ix));
FAIL(DeprecatedString::formatted("Key {}, index {} already found previously", *key_value, ix));
found[ix] = true;
break;
}
@ -288,7 +288,7 @@ void insert_into_and_scan_hash_index(int num_keys)
EXPECT_EQ(count, num_keys);
for (auto ix = 0; ix < num_keys; ix++) {
if (!found[ix])
FAIL(String::formatted("Key {}, index {} not found", keys[ix], ix));
FAIL(DeprecatedString::formatted("Key {}, index {} not found", keys[ix], ix));
}
}
}

View file

@ -21,7 +21,7 @@ namespace {
constexpr char const* db_name = "/tmp/test.db";
SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database, String const& sql)
SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database, DeprecatedString const& sql)
{
auto parser = SQL::AST::Parser(SQL::AST::Lexer(sql));
auto statement = parser.next_statement();
@ -31,7 +31,7 @@ SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database,
return statement->execute(move(database));
}
SQL::ResultSet execute(NonnullRefPtr<SQL::Database> database, String const& sql)
SQL::ResultSet execute(NonnullRefPtr<SQL::Database> database, DeprecatedString const& sql)
{
auto result = try_execute(move(database), sql);
if (result.is_error()) {
@ -531,7 +531,7 @@ TEST_CASE(select_with_limit)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10;");
@ -547,7 +547,7 @@ TEST_CASE(select_with_limit_and_offset)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10 OFFSET 10;");
@ -562,7 +562,7 @@ TEST_CASE(select_with_order_limit_and_offset)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY IntColumn LIMIT 10 OFFSET 10;");
@ -587,7 +587,7 @@ TEST_CASE(select_with_limit_out_of_bounds)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 500;");
@ -602,7 +602,7 @@ TEST_CASE(select_with_offset_out_of_bounds)
create_table(database);
for (auto count = 0; count < 100; count++) {
auto result = execute(database,
String::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
EXPECT(result.size() == 1);
}
auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10 OFFSET 200;");
@ -633,7 +633,7 @@ TEST_CASE(binary_operator_execution)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -707,7 +707,7 @@ TEST_CASE(binary_operator_failure)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -717,7 +717,7 @@ TEST_CASE(binary_operator_failure)
auto error = result.release_error();
EXPECT_EQ(error.error(), SQL::SQLErrorCode::NumericOperatorTypeMismatch);
auto message = String::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op);
auto message = DeprecatedString::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op);
EXPECT_EQ(error.error_string(), message);
};
@ -777,7 +777,7 @@ TEST_CASE(delete_single_row)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -821,7 +821,7 @@ TEST_CASE(delete_multiple_rows)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}
@ -861,7 +861,7 @@ TEST_CASE(delete_all_rows)
create_table(database);
for (auto count = 0; count < 10; ++count) {
auto result = execute(database, String::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
EXPECT_EQ(result.size(), 1u);
}

View file

@ -8,9 +8,9 @@
#include <LibTest/TestCase.h>
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/Result.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <AK/TypeCasts.h>
#include <AK/Vector.h>
@ -19,7 +19,7 @@
namespace {
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Statement>, String>;
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Statement>, DeprecatedString>;
ParseResult parse(StringView sql)
{
@ -392,7 +392,7 @@ TEST_CASE(update)
EXPECT(parse("UPDATE OR table_name SET column_name=4;"sv).is_error());
EXPECT(parse("UPDATE OR foo table_name SET column_name=4;"sv).is_error());
auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector<Vector<String>> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector<StringView> expected_returned_column_aliases) {
auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector<Vector<DeprecatedString>> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector<StringView> expected_returned_column_aliases) {
auto result = parse(sql);
EXPECT(!result.is_error());
@ -439,7 +439,7 @@ TEST_CASE(update)
}
};
Vector<Vector<String>> update_columns { { "COLUMN_NAME" } };
Vector<Vector<DeprecatedString>> update_columns { { "COLUMN_NAME" } };
validate("UPDATE OR ABORT table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Abort, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {});
validate("UPDATE OR FAIL table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Fail, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {});
validate("UPDATE OR IGNORE table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Ignore, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {});
@ -567,7 +567,7 @@ TEST_CASE(select)
};
struct Ordering {
String collation_name;
DeprecatedString collation_name;
SQL::Order order;
SQL::Nulls nulls;
};
@ -747,9 +747,9 @@ TEST_CASE(common_table_expression)
TEST_CASE(nested_subquery_limit)
{
auto subquery = String::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1);
EXPECT(!parse(String::formatted("SELECT * FROM {};"sv, subquery)).is_error());
EXPECT(parse(String::formatted("SELECT * FROM ({});"sv, subquery)).is_error());
auto subquery = DeprecatedString::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1);
EXPECT(!parse(DeprecatedString::formatted("SELECT * FROM {};"sv, subquery)).is_error());
EXPECT(parse(DeprecatedString::formatted("SELECT * FROM ({});"sv, subquery)).is_error());
}
TEST_CASE(describe_table)

View file

@ -47,11 +47,11 @@ TEST_CASE(text_value)
EXPECT_EQ(v.to_string(), "Test"sv);
}
{
SQL::Value v(String("String Test"sv));
SQL::Value v(DeprecatedString("String Test"sv));
EXPECT_EQ(v.type(), SQL::SQLType::Text);
EXPECT_EQ(v.to_string(), "String Test"sv);
v = String("String Test 2"sv);
v = DeprecatedString("String Test 2"sv);
EXPECT_EQ(v.type(), SQL::SQLType::Text);
EXPECT_EQ(v.to_string(), "String Test 2"sv);
}

View file

@ -23,14 +23,14 @@ static ByteBuffer operator""_b(char const* string, size_t length)
}
Vector<Certificate> load_certificates();
String locate_ca_certs_file();
DeprecatedString locate_ca_certs_file();
String locate_ca_certs_file()
DeprecatedString locate_ca_certs_file()
{
if (Core::File::exists(ca_certs_file)) {
return ca_certs_file;
}
auto on_target_path = String("/etc/ca_certs.ini");
auto on_target_path = DeprecatedString("/etc/ca_certs.ini");
if (Core::File::exists(on_target_path)) {
return on_target_path;
}

View file

@ -181,10 +181,10 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
[&](const auto& ref) -> JS::Value { return JS::Value(static_cast<double>(ref.address.value())); });
});
}
return vm.throw_completion<JS::TypeError>(String::formatted("'{}' does not refer to a function or a global", name));
return vm.throw_completion<JS::TypeError>(DeprecatedString::formatted("'{}' does not refer to a function or a global", name));
}
}
return vm.throw_completion<JS::TypeError>(String::formatted("'{}' could not be found", name));
return vm.throw_completion<JS::TypeError>(DeprecatedString::formatted("'{}' could not be found", name));
}
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke)
@ -202,7 +202,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke)
Vector<Wasm::Value> arguments;
if (type->parameters().size() + 1 > vm.argument_count())
return vm.throw_completion<JS::TypeError>(String::formatted("Expected {} arguments for call, but found {}", type->parameters().size() + 1, vm.argument_count()));
return vm.throw_completion<JS::TypeError>(DeprecatedString::formatted("Expected {} arguments for call, but found {}", type->parameters().size() + 1, vm.argument_count()));
size_t index = 1;
for (auto& param : type->parameters()) {
auto argument = vm.argument(index++);
@ -244,7 +244,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke)
auto result = WebAssemblyModule::machine().invoke(function_address, arguments);
if (result.is_trap())
return vm.throw_completion<JS::TypeError>(String::formatted("Execution trapped: {}", result.trap().reason));
return vm.throw_completion<JS::TypeError>(DeprecatedString::formatted("Execution trapped: {}", result.trap().reason));
if (result.values().is_empty())
return JS::js_null();

View file

@ -205,7 +205,7 @@ TEST_CASE(regression)
auto file_size = MUST(file->size());
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
MUST(file->read(content.bytes()));
String file_contents { content.bytes() };
DeprecatedString file_contents { content.bytes() };
auto tokens = run_tokenizer(file_contents);
u32 hash = hash_tokens(tokens);
EXPECT_EQ(hash, 710375345u);

View file

@ -15,7 +15,7 @@ static constexpr auto s_spreadsheet_runtime_path = "/res/js/Spreadsheet/runtime.
static constexpr auto s_spreadsheet_runtime_path = "../../../../Base/res/js/Spreadsheet/runtime.js"sv;
#endif
TESTJS_RUN_FILE_FUNCTION(String const&, JS::Interpreter& interpreter, JS::ExecutionContext& global_execution_context)
TESTJS_RUN_FILE_FUNCTION(DeprecatedString const&, JS::Interpreter& interpreter, JS::ExecutionContext& global_execution_context)
{
auto run_file = [&](StringView name) {
auto result = Test::JS::parse_script(name, interpreter.realm());