mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:07:34 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -13,13 +13,13 @@ set(AK_TEST_SOURCES
|
|||
TestBitStream.cpp
|
||||
TestBuiltinWrappers.cpp
|
||||
TestByteBuffer.cpp
|
||||
TestByteString.cpp
|
||||
TestCharacterTypes.cpp
|
||||
TestChecked.cpp
|
||||
TestCircularBuffer.cpp
|
||||
TestCircularDeque.cpp
|
||||
TestCircularQueue.cpp
|
||||
TestComplex.cpp
|
||||
TestDeprecatedString.cpp
|
||||
TestDisjointChunks.cpp
|
||||
TestDistinctNumeric.cpp
|
||||
TestDoublyLinkedList.cpp
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/Base64.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <string.h>
|
||||
|
||||
TEST_CASE(test_decode)
|
||||
{
|
||||
auto decode_equal = [&](StringView input, StringView expected) {
|
||||
auto decoded = TRY_OR_FAIL(decode_base64(input));
|
||||
EXPECT(DeprecatedString::copy(decoded) == expected);
|
||||
EXPECT(ByteString::copy(decoded) == expected);
|
||||
EXPECT(expected.length() <= calculate_base64_decoded_length(input.bytes()));
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/BinaryHeap.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
|
||||
using namespace Test::Randomized;
|
||||
|
||||
|
@ -46,7 +46,7 @@ TEST_CASE(populate_int)
|
|||
|
||||
TEST_CASE(populate_string)
|
||||
{
|
||||
BinaryHeap<int, DeprecatedString, 5> strings;
|
||||
BinaryHeap<int, ByteString, 5> strings;
|
||||
strings.insert(1, "ABC");
|
||||
strings.insert(2, "DEF");
|
||||
EXPECT_EQ(strings.size(), 2u);
|
||||
|
|
|
@ -51,20 +51,20 @@ TEST_CASE(array_doubles)
|
|||
|
||||
TEST_CASE(vector_strings)
|
||||
{
|
||||
Vector<DeprecatedString> strings;
|
||||
Vector<ByteString> strings;
|
||||
strings.append("bat");
|
||||
strings.append("cat");
|
||||
strings.append("dog");
|
||||
|
||||
auto string_compare = [](DeprecatedString const& a, DeprecatedString const& b) -> int {
|
||||
auto string_compare = [](ByteString const& a, ByteString const& b) -> int {
|
||||
return strcmp(a.characters(), b.characters());
|
||||
};
|
||||
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"));
|
||||
auto test1 = *binary_search(strings, ByteString("bat"), nullptr, string_compare);
|
||||
auto test2 = *binary_search(strings, ByteString("cat"), nullptr, string_compare);
|
||||
auto test3 = *binary_search(strings, ByteString("dog"), nullptr, string_compare);
|
||||
EXPECT_EQ(test1, ByteString("bat"));
|
||||
EXPECT_EQ(test2, ByteString("cat"));
|
||||
EXPECT_EQ(test3, ByteString("dog"));
|
||||
}
|
||||
|
||||
TEST_CASE(single_element)
|
||||
|
|
|
@ -6,26 +6,26 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <cstring>
|
||||
|
||||
TEST_CASE(construct_empty)
|
||||
{
|
||||
EXPECT(DeprecatedString().is_empty());
|
||||
EXPECT(DeprecatedString().characters() != nullptr);
|
||||
EXPECT(ByteString().is_empty());
|
||||
EXPECT(ByteString().characters() != nullptr);
|
||||
|
||||
EXPECT(DeprecatedString("").is_empty());
|
||||
EXPECT(DeprecatedString("").characters() != nullptr);
|
||||
EXPECT(ByteString("").is_empty());
|
||||
EXPECT(ByteString("").characters() != nullptr);
|
||||
|
||||
EXPECT(DeprecatedString("").impl() == DeprecatedString::empty().impl());
|
||||
EXPECT(ByteString("").impl() == ByteString::empty().impl());
|
||||
}
|
||||
|
||||
TEST_CASE(construct_contents)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString test_string = "ABCDEF";
|
||||
EXPECT(!test_string.is_empty());
|
||||
EXPECT_EQ(test_string.length(), 6u);
|
||||
EXPECT_EQ(test_string.length(), strlen(test_string.characters()));
|
||||
|
@ -39,45 +39,45 @@ TEST_CASE(construct_contents)
|
|||
|
||||
TEST_CASE(equal)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::empty(), DeprecatedString {});
|
||||
EXPECT_EQ(ByteString::empty(), ByteString {});
|
||||
}
|
||||
|
||||
TEST_CASE(compare)
|
||||
{
|
||||
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("a"sv < ByteString("b"));
|
||||
EXPECT(!("a"sv > ByteString("b")));
|
||||
EXPECT("b"sv > ByteString("a"));
|
||||
EXPECT(!("b"sv < ByteString("b")));
|
||||
EXPECT("a"sv >= ByteString("a"));
|
||||
EXPECT(!("a"sv >= ByteString("b")));
|
||||
EXPECT("a"sv <= ByteString("a"));
|
||||
EXPECT(!("b"sv <= ByteString("a")));
|
||||
|
||||
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(ByteString("a") > ByteString());
|
||||
EXPECT(!(ByteString() > ByteString("a")));
|
||||
EXPECT(ByteString() < ByteString("a"));
|
||||
EXPECT(!(ByteString("a") < ByteString()));
|
||||
EXPECT(ByteString("a") >= ByteString());
|
||||
EXPECT(!(ByteString() >= ByteString("a")));
|
||||
EXPECT(ByteString() <= ByteString("a"));
|
||||
EXPECT(!(ByteString("a") <= ByteString()));
|
||||
|
||||
EXPECT(!(DeprecatedString() > DeprecatedString()));
|
||||
EXPECT(!(DeprecatedString() < DeprecatedString()));
|
||||
EXPECT(DeprecatedString() >= DeprecatedString());
|
||||
EXPECT(DeprecatedString() <= DeprecatedString());
|
||||
EXPECT(!(ByteString() > ByteString()));
|
||||
EXPECT(!(ByteString() < ByteString()));
|
||||
EXPECT(ByteString() >= ByteString());
|
||||
EXPECT(ByteString() <= ByteString());
|
||||
}
|
||||
|
||||
TEST_CASE(index_access)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString test_string = "ABCDEF";
|
||||
EXPECT_EQ(test_string[0], 'A');
|
||||
EXPECT_EQ(test_string[1], 'B');
|
||||
}
|
||||
|
||||
TEST_CASE(starts_with)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString test_string = "ABCDEF";
|
||||
EXPECT(test_string.starts_with("AB"sv));
|
||||
EXPECT(test_string.starts_with('A'));
|
||||
EXPECT(!test_string.starts_with('B'));
|
||||
|
@ -89,7 +89,7 @@ TEST_CASE(starts_with)
|
|||
|
||||
TEST_CASE(ends_with)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString test_string = "ABCDEF";
|
||||
EXPECT(test_string.ends_with("EF"sv));
|
||||
EXPECT(test_string.ends_with('F'));
|
||||
EXPECT(!test_string.ends_with('E'));
|
||||
|
@ -101,7 +101,7 @@ TEST_CASE(ends_with)
|
|||
|
||||
TEST_CASE(copy_string)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString 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());
|
||||
|
@ -109,7 +109,7 @@ TEST_CASE(copy_string)
|
|||
|
||||
TEST_CASE(move_string)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString test_string = "ABCDEF";
|
||||
auto test_string_copy = test_string;
|
||||
auto test_string_move = move(test_string_copy);
|
||||
EXPECT_EQ(test_string, test_string_move);
|
||||
|
@ -118,25 +118,25 @@ TEST_CASE(move_string)
|
|||
|
||||
TEST_CASE(repeated)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::repeated('x', 0), "");
|
||||
EXPECT_EQ(DeprecatedString::repeated('x', 1), "x");
|
||||
EXPECT_EQ(DeprecatedString::repeated('x', 2), "xx");
|
||||
EXPECT_EQ(ByteString::repeated('x', 0), "");
|
||||
EXPECT_EQ(ByteString::repeated('x', 1), "x");
|
||||
EXPECT_EQ(ByteString::repeated('x', 2), "xx");
|
||||
}
|
||||
|
||||
TEST_CASE(to_int)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString("123").to_int().value(), 123);
|
||||
EXPECT_EQ(DeprecatedString("-123").to_int().value(), -123);
|
||||
EXPECT_EQ(ByteString("123").to_int().value(), 123);
|
||||
EXPECT_EQ(ByteString("-123").to_int().value(), -123);
|
||||
}
|
||||
|
||||
TEST_CASE(to_lowercase)
|
||||
{
|
||||
EXPECT(DeprecatedString("ABC").to_lowercase() == "abc");
|
||||
EXPECT(ByteString("ABC").to_lowercase() == "abc");
|
||||
}
|
||||
|
||||
TEST_CASE(to_uppercase)
|
||||
{
|
||||
EXPECT(DeprecatedString("AbC").to_uppercase() == "ABC");
|
||||
EXPECT(ByteString("AbC").to_uppercase() == "ABC");
|
||||
}
|
||||
|
||||
TEST_CASE(flystring)
|
||||
|
@ -148,12 +148,12 @@ TEST_CASE(flystring)
|
|||
}
|
||||
|
||||
{
|
||||
DeprecatedString a = "foo";
|
||||
ByteString a = "foo";
|
||||
DeprecatedFlyString b = a;
|
||||
StringBuilder builder;
|
||||
builder.append('f');
|
||||
builder.append("oo"sv);
|
||||
DeprecatedFlyString c = builder.to_deprecated_string();
|
||||
DeprecatedFlyString c = builder.to_byte_string();
|
||||
EXPECT_EQ(a.impl(), b.impl());
|
||||
EXPECT_EQ(a.impl(), c.impl());
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ TEST_CASE(flystring)
|
|||
|
||||
TEST_CASE(replace)
|
||||
{
|
||||
DeprecatedString test_string = "Well, hello Friends!";
|
||||
ByteString test_string = "Well, hello Friends!";
|
||||
|
||||
test_string = test_string.replace("Friends"sv, "Testers"sv, ReplaceMode::FirstOnly);
|
||||
EXPECT(test_string == "Well, hello Testers!");
|
||||
|
@ -172,7 +172,7 @@ TEST_CASE(replace)
|
|||
test_string = test_string.replace("!"sv, " :^)"sv, ReplaceMode::FirstOnly);
|
||||
EXPECT(test_string == "We're, he'reo Testers :^)");
|
||||
|
||||
test_string = DeprecatedString("111._.111._.111");
|
||||
test_string = ByteString("111._.111._.111");
|
||||
test_string = test_string.replace("111"sv, "|||"sv, ReplaceMode::All);
|
||||
EXPECT(test_string == "|||._.|||._.|||");
|
||||
|
||||
|
@ -182,7 +182,7 @@ TEST_CASE(replace)
|
|||
|
||||
TEST_CASE(count)
|
||||
{
|
||||
DeprecatedString test_string = "Well, hello Friends!";
|
||||
ByteString test_string = "Well, hello Friends!";
|
||||
u32 count = test_string.count("Friends"sv);
|
||||
EXPECT(count == 1);
|
||||
|
||||
|
@ -192,7 +192,7 @@ TEST_CASE(count)
|
|||
count = test_string.count("!"sv);
|
||||
EXPECT(count == 1);
|
||||
|
||||
test_string = DeprecatedString("111._.111._.111");
|
||||
test_string = ByteString("111._.111._.111");
|
||||
count = test_string.count("111"sv);
|
||||
EXPECT(count == 3);
|
||||
|
||||
|
@ -202,7 +202,7 @@ TEST_CASE(count)
|
|||
|
||||
TEST_CASE(substring)
|
||||
{
|
||||
DeprecatedString test = "abcdef";
|
||||
ByteString test = "abcdef";
|
||||
EXPECT_EQ(test.substring(0, 6), test);
|
||||
EXPECT_EQ(test.substring(0, 3), "abc");
|
||||
EXPECT_EQ(test.substring(3, 3), "def");
|
||||
|
@ -212,7 +212,7 @@ TEST_CASE(substring)
|
|||
|
||||
TEST_CASE(split)
|
||||
{
|
||||
DeprecatedString test = "foo bar baz";
|
||||
ByteString test = "foo bar baz";
|
||||
auto parts = test.split(' ');
|
||||
EXPECT_EQ(parts.size(), 3u);
|
||||
EXPECT_EQ(parts[0], "foo");
|
||||
|
@ -249,13 +249,13 @@ TEST_CASE(builder_zero_initial_capacity)
|
|||
{
|
||||
StringBuilder builder(0);
|
||||
builder.append(""sv);
|
||||
auto built = builder.to_deprecated_string();
|
||||
auto built = builder.to_byte_string();
|
||||
EXPECT_EQ(built.length(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(find)
|
||||
{
|
||||
DeprecatedString a = "foobarbar";
|
||||
ByteString 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 });
|
||||
|
@ -271,7 +271,7 @@ TEST_CASE(find)
|
|||
|
||||
TEST_CASE(find_with_empty_needle)
|
||||
{
|
||||
DeprecatedString string = "";
|
||||
ByteString string = "";
|
||||
EXPECT_EQ(string.find(""sv), 0u);
|
||||
EXPECT_EQ(string.find_all(""sv), (Vector<size_t> { 0u }));
|
||||
|
||||
|
@ -282,33 +282,33 @@ TEST_CASE(find_with_empty_needle)
|
|||
|
||||
TEST_CASE(bijective_base)
|
||||
{
|
||||
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(701), "ZZ");
|
||||
EXPECT_EQ(DeprecatedString::bijective_base_from(702), "AAA");
|
||||
EXPECT_EQ(DeprecatedString::bijective_base_from(730), "ABC");
|
||||
EXPECT_EQ(DeprecatedString::bijective_base_from(18277), "ZZZ");
|
||||
EXPECT_EQ(ByteString::bijective_base_from(0), "A");
|
||||
EXPECT_EQ(ByteString::bijective_base_from(25), "Z");
|
||||
EXPECT_EQ(ByteString::bijective_base_from(26), "AA");
|
||||
EXPECT_EQ(ByteString::bijective_base_from(52), "BA");
|
||||
EXPECT_EQ(ByteString::bijective_base_from(701), "ZZ");
|
||||
EXPECT_EQ(ByteString::bijective_base_from(702), "AAA");
|
||||
EXPECT_EQ(ByteString::bijective_base_from(730), "ABC");
|
||||
EXPECT_EQ(ByteString::bijective_base_from(18277), "ZZZ");
|
||||
}
|
||||
|
||||
TEST_CASE(roman_numerals)
|
||||
{
|
||||
auto zero = DeprecatedString::roman_number_from(0);
|
||||
auto zero = ByteString::roman_number_from(0);
|
||||
EXPECT_EQ(zero, "");
|
||||
|
||||
auto one = DeprecatedString::roman_number_from(1);
|
||||
auto one = ByteString::roman_number_from(1);
|
||||
EXPECT_EQ(one, "I");
|
||||
|
||||
auto nine = DeprecatedString::roman_number_from(9);
|
||||
auto nine = ByteString::roman_number_from(9);
|
||||
EXPECT_EQ(nine, "IX");
|
||||
|
||||
auto fourty_eight = DeprecatedString::roman_number_from(48);
|
||||
auto fourty_eight = ByteString::roman_number_from(48);
|
||||
EXPECT_EQ(fourty_eight, "XLVIII");
|
||||
|
||||
auto one_thousand_nine_hundred_ninety_eight = DeprecatedString::roman_number_from(1998);
|
||||
auto one_thousand_nine_hundred_ninety_eight = ByteString::roman_number_from(1998);
|
||||
EXPECT_EQ(one_thousand_nine_hundred_ninety_eight, "MCMXCVIII");
|
||||
|
||||
auto four_thousand = DeprecatedString::roman_number_from(4000);
|
||||
auto four_thousand = ByteString::roman_number_from(4000);
|
||||
EXPECT_EQ(four_thousand, "4000");
|
||||
}
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/CircularDeque.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
||||
TEST_CASE(enqueue_begin)
|
||||
|
@ -37,9 +37,9 @@ TEST_CASE(enqueue_begin)
|
|||
|
||||
TEST_CASE(enqueue_begin_being_moved_from)
|
||||
{
|
||||
CircularDeque<DeprecatedString, 2> strings;
|
||||
CircularDeque<ByteString, 2> strings;
|
||||
|
||||
DeprecatedString str { "test" };
|
||||
ByteString str { "test" };
|
||||
strings.enqueue_begin(move(str));
|
||||
EXPECT(str.is_empty());
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/CircularQueue.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
|
||||
TEST_CASE(basic)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ TEST_CASE(basic)
|
|||
|
||||
TEST_CASE(complex_type)
|
||||
{
|
||||
CircularQueue<DeprecatedString, 2> strings;
|
||||
CircularQueue<ByteString, 2> strings;
|
||||
|
||||
strings.enqueue("ABC");
|
||||
strings.enqueue("DEF");
|
||||
|
@ -44,7 +44,7 @@ TEST_CASE(complex_type)
|
|||
|
||||
TEST_CASE(complex_type_clear)
|
||||
{
|
||||
CircularQueue<DeprecatedString, 5> strings;
|
||||
CircularQueue<ByteString, 5> strings;
|
||||
strings.enqueue("xxx");
|
||||
strings.enqueue("xxx");
|
||||
strings.enqueue("xxx");
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/DisjointChunks.h>
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/Vector.h>
|
||||
|
|
|
@ -168,134 +168,134 @@ TEST_CASE(cast)
|
|||
|
||||
TEST_CASE(formatter)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(123.456)), "123.455993"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(-123.456)), "-123.455993"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);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.1)), "0.100006"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.02)), "0.020004"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.003)), "0.003005"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.0004)), "0.000396"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.0000000005)), "0"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(-0.1)), "-0.100006"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(-0.02)), "-0.020004"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(-0.0000000005)), "0"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(123.456)), "123.455993"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(-123.456)), "-123.455993"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<4>(123.456)), "123.4375"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<4>(-123.456)), "-123.4375"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16> {}), "0"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.1)), "0.100006"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.02)), "0.020004"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.003)), "0.003005"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.0004)), "0.000396"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.0000000005)), "0"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(-0.1)), "-0.100006"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(-0.02)), "-0.020004"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(-0.0000000005)), "0"sv);
|
||||
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", Type(-1)), "-1"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", Type(-2)), "-2"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", Type(-3)), "-3"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", Type(-1)), "-1"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", Type(-2)), "-2"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{}", Type(-3)), "-3"sv);
|
||||
|
||||
// exact representation
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30}", FixedPoint<16>(123.456)), "123.45599365234375"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30}", FixedPoint<16>(-0.1)), "-0.100006103515625"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30}", FixedPoint<16>(-0.02)), "-0.0200042724609375"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30}", FixedPoint<16>(123.456)), "123.45599365234375"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30}", FixedPoint<16>(-0.1)), "-0.100006103515625"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30}", FixedPoint<16>(-0.02)), "-0.0200042724609375"sv);
|
||||
|
||||
// maximum fraction per precision; 1 - 2^-precision
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<7, u64>::create_raw((1ull << 7) - 1)), "0.99218750000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<8, u64>::create_raw((1ull << 8) - 1)), "0.99609375000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<9, u64>::create_raw((1ull << 9) - 1)), "0.99804687500000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<10, u64>::create_raw((1ull << 10) - 1)), "0.99902343750000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.99951171875000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<12, u64>::create_raw((1ull << 12) - 1)), "0.99975585937500000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<13, u64>::create_raw((1ull << 13) - 1)), "0.99987792968750000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<14, u64>::create_raw((1ull << 14) - 1)), "0.99993896484375000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<15, u64>::create_raw((1ull << 15) - 1)), "0.99996948242187500000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<16, u64>::create_raw((1ull << 16) - 1)), "0.99998474121093750000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<17, u64>::create_raw((1ull << 17) - 1)), "0.99999237060546875000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<18, u64>::create_raw((1ull << 18) - 1)), "0.99999618530273437500"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<19, u64>::create_raw((1ull << 19) - 1)), "0.99999809265136718750"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<7, u64>::create_raw((1ull << 7) - 1)), "0.99218750000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<8, u64>::create_raw((1ull << 8) - 1)), "0.99609375000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<9, u64>::create_raw((1ull << 9) - 1)), "0.99804687500000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<10, u64>::create_raw((1ull << 10) - 1)), "0.99902343750000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.99951171875000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<12, u64>::create_raw((1ull << 12) - 1)), "0.99975585937500000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<13, u64>::create_raw((1ull << 13) - 1)), "0.99987792968750000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<14, u64>::create_raw((1ull << 14) - 1)), "0.99993896484375000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<15, u64>::create_raw((1ull << 15) - 1)), "0.99996948242187500000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<16, u64>::create_raw((1ull << 16) - 1)), "0.99998474121093750000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<17, u64>::create_raw((1ull << 17) - 1)), "0.99999237060546875000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<18, u64>::create_raw((1ull << 18) - 1)), "0.99999618530273437500"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<19, u64>::create_raw((1ull << 19) - 1)), "0.99999809265136718750"sv);
|
||||
// maximum factor and precision >= 20 bits/digits will overflow u64: (5^20)*(2^20 - 1) > 2^64
|
||||
// EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<20, u64>::create_raw((1ull << 20) - 1)), "0.99999904632568359375"sv);
|
||||
// EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<20, u64>::create_raw((1ull << 20) - 1)), "0.99999904632568359375"sv);
|
||||
|
||||
// minimum fraction per precision; 2^-precision
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<7, u64>::create_raw(1)), "0.007812500000000000000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<8, u64>::create_raw(1)), "0.003906250000000000000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<9, u64>::create_raw(1)), "0.001953125000000000000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<10, u64>::create_raw(1)), "0.000976562500000000000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<11, u64>::create_raw(1)), "0.000488281250000000000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<12, u64>::create_raw(1)), "0.000244140625000000000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<13, u64>::create_raw(1)), "0.000122070312500000000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<14, u64>::create_raw(1)), "0.000061035156250000000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<15, u64>::create_raw(1)), "0.000030517578125000000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<16, u64>::create_raw(1)), "0.000015258789062500000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<17, u64>::create_raw(1)), "0.000007629394531250000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<18, u64>::create_raw(1)), "0.000003814697265625000000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<19, u64>::create_raw(1)), "0.000001907348632812500000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<20, u64>::create_raw(1)), "0.000000953674316406250000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<21, u64>::create_raw(1)), "0.000000476837158203125000000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<22, u64>::create_raw(1)), "0.000000238418579101562500000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<23, u64>::create_raw(1)), "0.000000119209289550781250000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<24, u64>::create_raw(1)), "0.000000059604644775390625000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<25, u64>::create_raw(1)), "0.000000029802322387695312500000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<26, u64>::create_raw(1)), "0.000000014901161193847656250000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<27, u64>::create_raw(1)), "0.000000007450580596923828125000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<7, u64>::create_raw(1)), "0.007812500000000000000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<8, u64>::create_raw(1)), "0.003906250000000000000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<9, u64>::create_raw(1)), "0.001953125000000000000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<10, u64>::create_raw(1)), "0.000976562500000000000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<11, u64>::create_raw(1)), "0.000488281250000000000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<12, u64>::create_raw(1)), "0.000244140625000000000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<13, u64>::create_raw(1)), "0.000122070312500000000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<14, u64>::create_raw(1)), "0.000061035156250000000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<15, u64>::create_raw(1)), "0.000030517578125000000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<16, u64>::create_raw(1)), "0.000015258789062500000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<17, u64>::create_raw(1)), "0.000007629394531250000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<18, u64>::create_raw(1)), "0.000003814697265625000000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<19, u64>::create_raw(1)), "0.000001907348632812500000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<20, u64>::create_raw(1)), "0.000000953674316406250000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<21, u64>::create_raw(1)), "0.000000476837158203125000000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<22, u64>::create_raw(1)), "0.000000238418579101562500000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<23, u64>::create_raw(1)), "0.000000119209289550781250000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<24, u64>::create_raw(1)), "0.000000059604644775390625000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<25, u64>::create_raw(1)), "0.000000029802322387695312500000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<26, u64>::create_raw(1)), "0.000000014901161193847656250000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<27, u64>::create_raw(1)), "0.000000007450580596923828125000"sv);
|
||||
// minimum factor and precision >= 28 bits/digits will overflow u64: (5^28)*(1) > 2^64
|
||||
// EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<28, u64>::create_raw(1)), "0.000000003725290298461914062500"sv);
|
||||
// EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<28, u64>::create_raw(1)), "0.000000003725290298461914062500"sv);
|
||||
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:a}", FixedPoint<16>(42.42)), "2a.6b85"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:o}", FixedPoint<16>(42.42)), "52.327024"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:b}", FixedPoint<16>(42.42)), "101010.01101"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.10a}", FixedPoint<16>(69.69)), "45.b0a4000000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.10o}", FixedPoint<16>(69.69)), "105.5412200000"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.10b}", FixedPoint<16>(69.69)), "1000101.1011000010"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:a}", FixedPoint<16>(42.42)), "2a.6b85"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:o}", FixedPoint<16>(42.42)), "52.327024"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:b}", FixedPoint<16>(42.42)), "101010.01101"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.10a}", FixedPoint<16>(69.69)), "45.b0a4000000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.10o}", FixedPoint<16>(69.69)), "105.5412200000"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:0.10b}", FixedPoint<16>(69.69)), "1000101.1011000010"sv);
|
||||
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30o}", AK::FixedPoint<13, u64>::create_raw(1)), "0.00004"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30b}", AK::FixedPoint<13, u64>::create_raw(1)), "0.0000000000001"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30o}", AK::FixedPoint<21, u64>::create_raw(0211234567)), "21.1234567"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30b}", AK::FixedPoint<13, u64>::create_raw(0b110011011010110)), "11.001101101011"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30o}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.7776"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30b}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.11111111111"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30o}", AK::FixedPoint<13, u64>::create_raw(1)), "0.00004"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30b}", AK::FixedPoint<13, u64>::create_raw(1)), "0.0000000000001"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30o}", AK::FixedPoint<21, u64>::create_raw(0211234567)), "21.1234567"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30b}", AK::FixedPoint<13, u64>::create_raw(0b110011011010110)), "11.001101101011"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30o}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.7776"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30b}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.11111111111"sv);
|
||||
|
||||
// maximum fraction per precision rendered in hexadecimal; 1 - 2^-precision; no overflow
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<7, u64>::create_raw((1ull << 7) - 1)), "0.fe"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<8, u64>::create_raw((1ull << 8) - 1)), "0.ff"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<9, u64>::create_raw((1ull << 9) - 1)), "0.ff8"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<10, u64>::create_raw((1ull << 10) - 1)), "0.ffc"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.ffe"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<12, u64>::create_raw((1ull << 12) - 1)), "0.fff"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<13, u64>::create_raw((1ull << 13) - 1)), "0.fff8"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<14, u64>::create_raw((1ull << 14) - 1)), "0.fffc"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<15, u64>::create_raw((1ull << 15) - 1)), "0.fffe"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<16, u64>::create_raw((1ull << 16) - 1)), "0.ffff"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<17, u64>::create_raw((1ull << 17) - 1)), "0.ffff8"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<18, u64>::create_raw((1ull << 18) - 1)), "0.ffffc"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<19, u64>::create_raw((1ull << 19) - 1)), "0.ffffe"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<20, u64>::create_raw((1ull << 20) - 1)), "0.fffff"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<21, u64>::create_raw((1ull << 21) - 1)), "0.fffff8"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<7, u64>::create_raw((1ull << 7) - 1)), "0.fe"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<8, u64>::create_raw((1ull << 8) - 1)), "0.ff"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<9, u64>::create_raw((1ull << 9) - 1)), "0.ff8"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<10, u64>::create_raw((1ull << 10) - 1)), "0.ffc"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.ffe"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<12, u64>::create_raw((1ull << 12) - 1)), "0.fff"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<13, u64>::create_raw((1ull << 13) - 1)), "0.fff8"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<14, u64>::create_raw((1ull << 14) - 1)), "0.fffc"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<15, u64>::create_raw((1ull << 15) - 1)), "0.fffe"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<16, u64>::create_raw((1ull << 16) - 1)), "0.ffff"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<17, u64>::create_raw((1ull << 17) - 1)), "0.ffff8"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<18, u64>::create_raw((1ull << 18) - 1)), "0.ffffc"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<19, u64>::create_raw((1ull << 19) - 1)), "0.ffffe"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<20, u64>::create_raw((1ull << 20) - 1)), "0.fffff"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<21, u64>::create_raw((1ull << 21) - 1)), "0.fffff8"sv);
|
||||
// ...skip some precisions
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<56, u64>::create_raw((1ull << 56) - 1)), "0.ffffffffffffff"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<57, u64>::create_raw((1ull << 57) - 1)), "0.ffffffffffffff8"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<58, u64>::create_raw((1ull << 58) - 1)), "0.ffffffffffffffc"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<59, u64>::create_raw((1ull << 59) - 1)), "0.ffffffffffffffe"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<60, u64>::create_raw((1ull << 60) - 1)), "0.fffffffffffffff"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<61, u64>::create_raw((1ull << 61) - 1)), "0.fffffffffffffff8"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<62, u64>::create_raw((1ull << 62) - 1)), "0.fffffffffffffffc"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<63, u64>::create_raw((1ull << 63) - 1)), "0.fffffffffffffffe"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<56, u64>::create_raw((1ull << 56) - 1)), "0.ffffffffffffff"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<57, u64>::create_raw((1ull << 57) - 1)), "0.ffffffffffffff8"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<58, u64>::create_raw((1ull << 58) - 1)), "0.ffffffffffffffc"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<59, u64>::create_raw((1ull << 59) - 1)), "0.ffffffffffffffe"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<60, u64>::create_raw((1ull << 60) - 1)), "0.fffffffffffffff"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<61, u64>::create_raw((1ull << 61) - 1)), "0.fffffffffffffff8"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<62, u64>::create_raw((1ull << 62) - 1)), "0.fffffffffffffffc"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<63, u64>::create_raw((1ull << 63) - 1)), "0.fffffffffffffffe"sv);
|
||||
|
||||
// minimum fraction per precision rendered in hexadecimal; 2^-precision; no overflow
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<7, u64>::create_raw(1)), "0.02"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<8, u64>::create_raw(1)), "0.01"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<9, u64>::create_raw(1)), "0.008"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<10, u64>::create_raw(1)), "0.004"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<11, u64>::create_raw(1)), "0.002"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<12, u64>::create_raw(1)), "0.001"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<13, u64>::create_raw(1)), "0.0008"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<14, u64>::create_raw(1)), "0.0004"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<15, u64>::create_raw(1)), "0.0002"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<16, u64>::create_raw(1)), "0.0001"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<17, u64>::create_raw(1)), "0.00008"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<18, u64>::create_raw(1)), "0.00004"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<19, u64>::create_raw(1)), "0.00002"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<20, u64>::create_raw(1)), "0.00001"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<21, u64>::create_raw(1)), "0.000008"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<7, u64>::create_raw(1)), "0.02"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<8, u64>::create_raw(1)), "0.01"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<9, u64>::create_raw(1)), "0.008"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<10, u64>::create_raw(1)), "0.004"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<11, u64>::create_raw(1)), "0.002"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<12, u64>::create_raw(1)), "0.001"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<13, u64>::create_raw(1)), "0.0008"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<14, u64>::create_raw(1)), "0.0004"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<15, u64>::create_raw(1)), "0.0002"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<16, u64>::create_raw(1)), "0.0001"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<17, u64>::create_raw(1)), "0.00008"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<18, u64>::create_raw(1)), "0.00004"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<19, u64>::create_raw(1)), "0.00002"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<20, u64>::create_raw(1)), "0.00001"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<21, u64>::create_raw(1)), "0.000008"sv);
|
||||
// ..skip some precisions
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<56, u64>::create_raw(1)), "0.00000000000001"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<57, u64>::create_raw(1)), "0.000000000000008"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<58, u64>::create_raw(1)), "0.000000000000004"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<59, u64>::create_raw(1)), "0.000000000000002"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<60, u64>::create_raw(1)), "0.000000000000001"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<61, u64>::create_raw(1)), "0.0000000000000008"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<62, u64>::create_raw(1)), "0.0000000000000004"sv);
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<63, u64>::create_raw(1)), "0.0000000000000002"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<56, u64>::create_raw(1)), "0.00000000000001"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<57, u64>::create_raw(1)), "0.000000000000008"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<58, u64>::create_raw(1)), "0.000000000000004"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<59, u64>::create_raw(1)), "0.000000000000002"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<60, u64>::create_raw(1)), "0.000000000000001"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<61, u64>::create_raw(1)), "0.0000000000000008"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<62, u64>::create_raw(1)), "0.0000000000000004"sv);
|
||||
EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<63, u64>::create_raw(1)), "0.0000000000000002"sv);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <math.h>
|
||||
|
@ -20,55 +20,55 @@ TEST_CASE(is_integral_works_properly)
|
|||
|
||||
TEST_CASE(format_string_literals)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("prefix-{}-suffix", "abc"), "prefix-abc-suffix");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}{}{}", "a", "b", "c"), "abc");
|
||||
EXPECT_EQ(ByteString::formatted("prefix-{}-suffix", "abc"), "prefix-abc-suffix");
|
||||
EXPECT_EQ(ByteString::formatted("{}{}{}", "a", "b", "c"), "abc");
|
||||
}
|
||||
|
||||
TEST_CASE(format_integers)
|
||||
{
|
||||
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");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", AK::NumericLimits<i64>::min()), "-9223372036854775808");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:x}", AK::NumericLimits<i64>::min()), "-8000000000000000");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'}", 0), "0");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'}", 4096), "4,096");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'}", 16777216), "16,777,216");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'}", AK::NumericLimits<u64>::max()), "18,446,744,073,709,551,615");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'}", AK::NumericLimits<u64>::max()), "18,446,744,073,709,551,615");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'}", AK::NumericLimits<i64>::min() + 1), "-9,223,372,036,854,775,807");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'x}", 0), "0");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'x}", 16777216), "1,000,000");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'x}", AK::NumericLimits<u64>::max()), "f,fff,fff,fff,fff,fff");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'x}", AK::NumericLimits<i64>::min() + 1), "-7,fff,fff,fff,fff,fff");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'b}", AK::NumericLimits<u64>::max()), "1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111");
|
||||
EXPECT_EQ(ByteString::formatted("{}", 42u), "42");
|
||||
EXPECT_EQ(ByteString::formatted("{:4}", 42u), " 42");
|
||||
EXPECT_EQ(ByteString::formatted("{:08}", 42u), "00000042");
|
||||
EXPECT_EQ(ByteString::formatted("{:7}", -17), " -17");
|
||||
EXPECT_EQ(ByteString::formatted("{}", -17), "-17");
|
||||
EXPECT_EQ(ByteString::formatted("{:04}", 13), "0013");
|
||||
EXPECT_EQ(ByteString::formatted("{:08x}", 4096), "00001000");
|
||||
EXPECT_EQ(ByteString::formatted("{:x}", 0x1111222233334444ull), "1111222233334444");
|
||||
EXPECT_EQ(ByteString::formatted("{:4}", 12345678), "12345678");
|
||||
EXPECT_EQ(ByteString::formatted("{}", AK::NumericLimits<i64>::min()), "-9223372036854775808");
|
||||
EXPECT_EQ(ByteString::formatted("{:x}", AK::NumericLimits<i64>::min()), "-8000000000000000");
|
||||
EXPECT_EQ(ByteString::formatted("{:'}", 0), "0");
|
||||
EXPECT_EQ(ByteString::formatted("{:'}", 4096), "4,096");
|
||||
EXPECT_EQ(ByteString::formatted("{:'}", 16777216), "16,777,216");
|
||||
EXPECT_EQ(ByteString::formatted("{:'}", AK::NumericLimits<u64>::max()), "18,446,744,073,709,551,615");
|
||||
EXPECT_EQ(ByteString::formatted("{:'}", AK::NumericLimits<u64>::max()), "18,446,744,073,709,551,615");
|
||||
EXPECT_EQ(ByteString::formatted("{:'}", AK::NumericLimits<i64>::min() + 1), "-9,223,372,036,854,775,807");
|
||||
EXPECT_EQ(ByteString::formatted("{:'x}", 0), "0");
|
||||
EXPECT_EQ(ByteString::formatted("{:'x}", 16777216), "1,000,000");
|
||||
EXPECT_EQ(ByteString::formatted("{:'x}", AK::NumericLimits<u64>::max()), "f,fff,fff,fff,fff,fff");
|
||||
EXPECT_EQ(ByteString::formatted("{:'x}", AK::NumericLimits<i64>::min() + 1), "-7,fff,fff,fff,fff,fff");
|
||||
EXPECT_EQ(ByteString::formatted("{:'b}", AK::NumericLimits<u64>::max()), "1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111");
|
||||
}
|
||||
|
||||
TEST_CASE(reorder_format_arguments)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{1}{0}", "a", "b"), "ba");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{0}{1}", "a", "b"), "ab");
|
||||
EXPECT_EQ(ByteString::formatted("{1}{0}", "a", "b"), "ba");
|
||||
EXPECT_EQ(ByteString::formatted("{0}{1}", "a", "b"), "ab");
|
||||
// Compiletime check bypass: ignoring a passed argument.
|
||||
EXPECT_EQ(DeprecatedString::formatted("{0}{0}{0}"sv, "a", "b"), "aaa");
|
||||
EXPECT_EQ(ByteString::formatted("{0}{0}{0}"sv, "a", "b"), "aaa");
|
||||
// Compiletime check bypass: ignoring a passed argument.
|
||||
EXPECT_EQ(DeprecatedString::formatted("{1}{}{0}"sv, "a", "b", "c"), "baa");
|
||||
EXPECT_EQ(ByteString::formatted("{1}{}{0}"sv, "a", "b", "c"), "baa");
|
||||
}
|
||||
|
||||
TEST_CASE(escape_braces)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{{{}", "foo"), "{foo");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}}}", "bar"), "bar}");
|
||||
EXPECT_EQ(ByteString::formatted("{{{}", "foo"), "{foo");
|
||||
EXPECT_EQ(ByteString::formatted("{}}}", "bar"), "bar}");
|
||||
}
|
||||
|
||||
TEST_CASE(everything)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{{{:04}/{}/{0:8}/{1}", 42u, "foo"), "{0042/foo/ 42/foo");
|
||||
EXPECT_EQ(ByteString::formatted("{{{:04}/{}/{0:8}/{1}", 42u, "foo"), "{0042/foo/ 42/foo");
|
||||
}
|
||||
|
||||
TEST_CASE(string_builder)
|
||||
|
@ -77,92 +77,92 @@ TEST_CASE(string_builder)
|
|||
builder.appendff(" {} ", 42);
|
||||
builder.appendff("{1}{0} ", 1, 2);
|
||||
|
||||
EXPECT_EQ(builder.to_deprecated_string(), " 42 21 ");
|
||||
EXPECT_EQ(builder.to_byte_string(), " 42 21 ");
|
||||
}
|
||||
|
||||
TEST_CASE(format_without_arguments)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("foo"), "foo");
|
||||
EXPECT_EQ(ByteString::formatted("foo"), "foo");
|
||||
}
|
||||
|
||||
TEST_CASE(format_upper_case_integer)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:4X}", 0xff), " FF");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:#4X}", 0xff), "0XFF");
|
||||
EXPECT_EQ(ByteString::formatted("{:4X}", 0xff), " FF");
|
||||
EXPECT_EQ(ByteString::formatted("{:#4X}", 0xff), "0XFF");
|
||||
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:b}", 0xff), "11111111");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:B}", 0xff), "11111111");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:#b}", 0xff), "0b11111111");
|
||||
EXPECT_EQ(ByteString::formatted("{:b}", 0xff), "11111111");
|
||||
EXPECT_EQ(ByteString::formatted("{:B}", 0xff), "11111111");
|
||||
EXPECT_EQ(ByteString::formatted("{:#b}", 0xff), "0b11111111");
|
||||
}
|
||||
|
||||
TEST_CASE(format_aligned)
|
||||
{
|
||||
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***");
|
||||
EXPECT_EQ(ByteString::formatted("{:*<8}", 13), "13******");
|
||||
EXPECT_EQ(ByteString::formatted("{:*^8}", 13), "***13***");
|
||||
EXPECT_EQ(ByteString::formatted("{:*>8}", 13), "******13");
|
||||
EXPECT_EQ(ByteString::formatted("{:*>+8}", 13), "*****+13");
|
||||
EXPECT_EQ(ByteString::formatted("{:*^ 8}", 13), "** 13***");
|
||||
}
|
||||
|
||||
TEST_CASE(format_octal)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:o}", 0744), "744");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:#o}", 0744), "0744");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'o}", 054321), "54,321");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'o}", 0567012340), "567,012,340");
|
||||
EXPECT_EQ(ByteString::formatted("{:o}", 0744), "744");
|
||||
EXPECT_EQ(ByteString::formatted("{:#o}", 0744), "0744");
|
||||
EXPECT_EQ(ByteString::formatted("{:'o}", 054321), "54,321");
|
||||
EXPECT_EQ(ByteString::formatted("{:'o}", 0567012340), "567,012,340");
|
||||
}
|
||||
|
||||
TEST_CASE(zero_pad)
|
||||
{
|
||||
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");
|
||||
EXPECT_EQ(ByteString::formatted("{: <010}", 42), "42 ");
|
||||
EXPECT_EQ(ByteString::formatted("{:010}", 42), "0000000042");
|
||||
EXPECT_EQ(ByteString::formatted("{:/^010}", 42), "////42////");
|
||||
EXPECT_EQ(ByteString::formatted("{:04x}", -32), "-0020");
|
||||
EXPECT_EQ(ByteString::formatted("{:#06x}", -64), "-0x000040");
|
||||
}
|
||||
|
||||
TEST_CASE(replacement_field)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:*>{1}}", 13, static_cast<size_t>(10)), "********13");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:*<{1}}", 7, 4), "7***");
|
||||
EXPECT_EQ(ByteString::formatted("{:*>{1}}", 13, static_cast<size_t>(10)), "********13");
|
||||
EXPECT_EQ(ByteString::formatted("{:*<{1}}", 7, 4), "7***");
|
||||
// Compiletime check bypass: intentionally ignoring extra arguments
|
||||
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");
|
||||
EXPECT_EQ(ByteString::formatted("{:{2}}"sv, -5, 8, 16), " -5");
|
||||
EXPECT_EQ(ByteString::formatted("{{{:*^{1}}}}", 1, 3), "{*1*}");
|
||||
EXPECT_EQ(ByteString::formatted("{:0{}}", 1, 3), "001");
|
||||
}
|
||||
|
||||
TEST_CASE(replacement_field_regression)
|
||||
{
|
||||
// FIXME: Compiletime check bypass: cannot parse '}}' correctly.
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:{}}"sv, "", static_cast<unsigned long>(6)), " ");
|
||||
EXPECT_EQ(ByteString::formatted("{:{}}"sv, "", static_cast<unsigned long>(6)), " ");
|
||||
}
|
||||
|
||||
TEST_CASE(complex_string_specifiers)
|
||||
{
|
||||
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");
|
||||
EXPECT_EQ(ByteString::formatted("{:.8}", "123456789"), "12345678");
|
||||
EXPECT_EQ(ByteString::formatted("{:9}", "abcd"), "abcd ");
|
||||
EXPECT_EQ(ByteString::formatted("{:>9}", "abcd"), " abcd");
|
||||
EXPECT_EQ(ByteString::formatted("{:^9}", "abcd"), " abcd ");
|
||||
EXPECT_EQ(ByteString::formatted("{:4.6}", "a"), "a ");
|
||||
EXPECT_EQ(ByteString::formatted("{:4.6}", "abcdef"), "abcdef");
|
||||
EXPECT_EQ(ByteString::formatted("{:4.6}", "abcdefghi"), "abcdef");
|
||||
}
|
||||
|
||||
TEST_CASE(cast_integer_to_character)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:c}", static_cast<int>('a')), "a");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:c}", static_cast<unsigned int>('f')), "f");
|
||||
EXPECT_EQ(ByteString::formatted("{:c}", static_cast<int>('a')), "a");
|
||||
EXPECT_EQ(ByteString::formatted("{:c}", static_cast<unsigned int>('f')), "f");
|
||||
}
|
||||
|
||||
TEST_CASE(boolean_values)
|
||||
{
|
||||
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");
|
||||
EXPECT_EQ(ByteString::formatted("{}", true), "true");
|
||||
EXPECT_EQ(ByteString::formatted("{}", false), "false");
|
||||
EXPECT_EQ(ByteString::formatted("{:6}", true), "true ");
|
||||
EXPECT_EQ(ByteString::formatted("{:>4}", false), "false");
|
||||
EXPECT_EQ(ByteString::formatted("{:d}", false), "0");
|
||||
EXPECT_EQ(ByteString::formatted("{:d}", true), "1");
|
||||
EXPECT_EQ(ByteString::formatted("{:#08x}", true), "0x00000001");
|
||||
}
|
||||
|
||||
TEST_CASE(pointers)
|
||||
|
@ -170,13 +170,13 @@ TEST_CASE(pointers)
|
|||
void* ptr = reinterpret_cast<void*>(0x4000);
|
||||
|
||||
if (sizeof(void*) == 4) {
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:p}", 32), "0x00000020");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:p}", ptr), "0x00004000");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", ptr), "0x00004000");
|
||||
EXPECT_EQ(ByteString::formatted("{:p}", 32), "0x00000020");
|
||||
EXPECT_EQ(ByteString::formatted("{:p}", ptr), "0x00004000");
|
||||
EXPECT_EQ(ByteString::formatted("{}", ptr), "0x00004000");
|
||||
} else if (sizeof(void*) == 8) {
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:p}", 32), "0x0000000000000020");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:p}", ptr), "0x0000000000004000");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", ptr), "0x0000000000004000");
|
||||
EXPECT_EQ(ByteString::formatted("{:p}", 32), "0x0000000000000020");
|
||||
EXPECT_EQ(ByteString::formatted("{:p}", ptr), "0x0000000000004000");
|
||||
EXPECT_EQ(ByteString::formatted("{}", ptr), "0x0000000000004000");
|
||||
} else {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -188,12 +188,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 (DeprecatedString::formatted("FAIL") != "FAIL") {
|
||||
if (ByteString::formatted("FAIL") != "FAIL") {
|
||||
fprintf(stderr, "FAIL\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (DeprecatedString::formatted("{} FAIL {}", 1, 2) != "1 FAIL 2") {
|
||||
if (ByteString::formatted("{} FAIL {}", 1, 2) != "1 FAIL 2") {
|
||||
fprintf(stderr, "FAIL\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -202,13 +202,13 @@ TEST_CASE(ensure_that_format_works)
|
|||
TEST_CASE(format_string_literal_as_pointer)
|
||||
{
|
||||
char const* literal = "abc";
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:p}", literal), DeprecatedString::formatted("{:p}", reinterpret_cast<FlatPtr>(literal)));
|
||||
EXPECT_EQ(ByteString::formatted("{:p}", literal), ByteString::formatted("{:p}", reinterpret_cast<FlatPtr>(literal)));
|
||||
}
|
||||
|
||||
TEST_CASE(format_character)
|
||||
{
|
||||
char a = 'a';
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", true ? a : 'b'), "a");
|
||||
EXPECT_EQ(ByteString::formatted("{}", true ? a : 'b'), "a");
|
||||
}
|
||||
|
||||
struct A {
|
||||
|
@ -225,8 +225,8 @@ struct AK::Formatter<B> : Formatter<StringView> {
|
|||
|
||||
TEST_CASE(format_if_supported)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FormatIfSupported { A {} }), "?");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", FormatIfSupported { B {} }), "B");
|
||||
EXPECT_EQ(ByteString::formatted("{}", FormatIfSupported { A {} }), "?");
|
||||
EXPECT_EQ(ByteString::formatted("{}", FormatIfSupported { B {} }), "B");
|
||||
}
|
||||
|
||||
TEST_CASE(file_descriptor)
|
||||
|
@ -254,39 +254,39 @@ TEST_CASE(file_descriptor)
|
|||
|
||||
TEST_CASE(floating_point_numbers)
|
||||
{
|
||||
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(DeprecatedString::formatted("{:'.4}", 1234.5678), "1,234.5678");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:'.4}", -1234.5678), "-1,234.5678");
|
||||
EXPECT_EQ(ByteString::formatted("{}", 1.12), "1.12");
|
||||
EXPECT_EQ(ByteString::formatted("{}", 1.), "1");
|
||||
EXPECT_EQ(ByteString::formatted("{:.3}", 1.12), "1.12");
|
||||
EXPECT_EQ(ByteString::formatted("{:.1}", 1.12), "1.1");
|
||||
EXPECT_EQ(ByteString::formatted("{}", -1.12), "-1.12");
|
||||
EXPECT_EQ(ByteString::formatted("{:'.4}", 1234.5678), "1,234.5678");
|
||||
EXPECT_EQ(ByteString::formatted("{:'.4}", -1234.5678), "-1,234.5678");
|
||||
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30f}", 1.0), "1.000000000000000000000000000000");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30f}", 1.5), "1.500000000000000000000000000000");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.30f}", -2.0), "-2.000000000000000000000000000000");
|
||||
EXPECT_EQ(ByteString::formatted("{:.30f}", 1.0), "1.000000000000000000000000000000");
|
||||
EXPECT_EQ(ByteString::formatted("{:.30f}", 1.5), "1.500000000000000000000000000000");
|
||||
EXPECT_EQ(ByteString::formatted("{:.30f}", -2.0), "-2.000000000000000000000000000000");
|
||||
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.0f}", 1.4), "1");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.0f}", 1.5), "2");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.0f}", -1.9), "-2");
|
||||
EXPECT_EQ(ByteString::formatted("{:.0f}", 1.4), "1");
|
||||
EXPECT_EQ(ByteString::formatted("{:.0f}", 1.5), "2");
|
||||
EXPECT_EQ(ByteString::formatted("{:.0f}", -1.9), "-2");
|
||||
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.1f}", 1.4), "1.4");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.1f}", 1.99), "2.0");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.1f}", 9.999), "10.0");
|
||||
EXPECT_EQ(ByteString::formatted("{:.1f}", 1.4), "1.4");
|
||||
EXPECT_EQ(ByteString::formatted("{:.1f}", 1.99), "2.0");
|
||||
EXPECT_EQ(ByteString::formatted("{:.1f}", 9.999), "10.0");
|
||||
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", NAN), "nan");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", INFINITY), "inf");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", -INFINITY), "-inf");
|
||||
EXPECT_EQ(ByteString::formatted("{}", NAN), "nan");
|
||||
EXPECT_EQ(ByteString::formatted("{}", INFINITY), "inf");
|
||||
EXPECT_EQ(ByteString::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(DeprecatedString::formatted("{:x>5.1}", 1.12), "xx1.1");
|
||||
EXPECT_EQ(ByteString::formatted("{:x>5.1}", 1.12), "xx1.1");
|
||||
}
|
||||
|
||||
TEST_CASE(floating_point_default_precision)
|
||||
{
|
||||
#define EXPECT_FORMAT(lit, value) \
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", lit), value##sv)
|
||||
EXPECT_EQ(ByteString::formatted("{}", lit), value##sv)
|
||||
|
||||
EXPECT_FORMAT(10.3f, "10.3");
|
||||
EXPECT_FORMAT(123e4f, "1230000");
|
||||
|
@ -307,24 +307,24 @@ TEST_CASE(floating_point_default_precision)
|
|||
|
||||
TEST_CASE(no_precision_no_trailing_number)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:.0}", 0.1), "0");
|
||||
EXPECT_EQ(ByteString::formatted("{:.0}", 0.1), "0");
|
||||
}
|
||||
|
||||
TEST_CASE(precision_with_trailing_zeros)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.3}", 1.12), "1.120");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:0.1}", 1.12), "1.1");
|
||||
EXPECT_EQ(ByteString::formatted("{:0.3}", 1.12), "1.120");
|
||||
EXPECT_EQ(ByteString::formatted("{:0.1}", 1.12), "1.1");
|
||||
}
|
||||
|
||||
TEST_CASE(magnitude_less_than_zero)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", -0.654), "-0.654");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", 0.654), "0.654");
|
||||
EXPECT_EQ(ByteString::formatted("{}", -0.654), "-0.654");
|
||||
EXPECT_EQ(ByteString::formatted("{}", 0.654), "0.654");
|
||||
}
|
||||
|
||||
TEST_CASE(format_nullptr)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", nullptr), DeprecatedString::formatted("{:p}", static_cast<FlatPtr>(0)));
|
||||
EXPECT_EQ(ByteString::formatted("{}", nullptr), ByteString::formatted("{:p}", static_cast<FlatPtr>(0)));
|
||||
}
|
||||
|
||||
struct C {
|
||||
|
@ -340,12 +340,12 @@ struct AK::Formatter<C> : AK::Formatter<FormatString> {
|
|||
|
||||
TEST_CASE(use_format_string_formatter)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:*<10}", C { 42 }), "C(i=42)***");
|
||||
EXPECT_EQ(ByteString::formatted("{:*<10}", C { 42 }), "C(i=42)***");
|
||||
}
|
||||
|
||||
TEST_CASE(long_long_regression)
|
||||
{
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", 0x0123456789abcdefLL), "81985529216486895");
|
||||
EXPECT_EQ(ByteString::formatted("{}", 0x0123456789abcdefLL), "81985529216486895");
|
||||
|
||||
StringBuilder builder;
|
||||
AK::FormatBuilder fmtbuilder { builder };
|
||||
|
@ -356,28 +356,28 @@ TEST_CASE(long_long_regression)
|
|||
|
||||
TEST_CASE(hex_dump)
|
||||
{
|
||||
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");
|
||||
EXPECT_EQ(ByteString::formatted("{:hex-dump}", "0000"), "30303030");
|
||||
EXPECT_EQ(ByteString::formatted("{:>4hex-dump}", "0000"), "30303030 0000");
|
||||
EXPECT_EQ(ByteString::formatted("{:>2hex-dump}", "0000"), "3030 00\n3030 00");
|
||||
EXPECT_EQ(ByteString::formatted("{:*>4hex-dump}", "0000"), "30303030****0000");
|
||||
}
|
||||
|
||||
TEST_CASE(span_format)
|
||||
{
|
||||
{
|
||||
Vector<int> v { 1, 2, 3, 4 };
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", v.span()), "[ 1, 2, 3, 4 ]");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", const_cast<AddConst<decltype(v)>&>(v).span()), "[ 1, 2, 3, 4 ]");
|
||||
EXPECT_EQ(ByteString::formatted("{}", v.span()), "[ 1, 2, 3, 4 ]");
|
||||
EXPECT_EQ(ByteString::formatted("{}", const_cast<AddConst<decltype(v)>&>(v).span()), "[ 1, 2, 3, 4 ]");
|
||||
}
|
||||
{
|
||||
Vector<StringView> v { "1"sv, "2"sv, "3"sv, "4"sv };
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", v.span()), "[ 1, 2, 3, 4 ]");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", const_cast<AddConst<decltype(v)>&>(v).span()), "[ 1, 2, 3, 4 ]");
|
||||
EXPECT_EQ(ByteString::formatted("{}", v.span()), "[ 1, 2, 3, 4 ]");
|
||||
EXPECT_EQ(ByteString::formatted("{}", const_cast<AddConst<decltype(v)>&>(v).span()), "[ 1, 2, 3, 4 ]");
|
||||
}
|
||||
{
|
||||
Vector<Vector<DeprecatedString>> v { { "1"sv, "2"sv }, { "3"sv, "4"sv } };
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", v.span()), "[ [ 1, 2 ], [ 3, 4 ] ]");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", const_cast<AddConst<decltype(v)>&>(v).span()), "[ [ 1, 2 ], [ 3, 4 ] ]");
|
||||
Vector<Vector<ByteString>> v { { "1"sv, "2"sv }, { "3"sv, "4"sv } };
|
||||
EXPECT_EQ(ByteString::formatted("{}", v.span()), "[ [ 1, 2 ], [ 3, 4 ] ]");
|
||||
EXPECT_EQ(ByteString::formatted("{}", const_cast<AddConst<decltype(v)>&>(v).span()), "[ [ 1, 2 ], [ 3, 4 ] ]");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,28 +385,28 @@ TEST_CASE(vector_format)
|
|||
{
|
||||
{
|
||||
Vector<int> v { 1, 2, 3, 4 };
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", v), "[ 1, 2, 3, 4 ]");
|
||||
EXPECT_EQ(ByteString::formatted("{}", v), "[ 1, 2, 3, 4 ]");
|
||||
}
|
||||
{
|
||||
Vector<StringView> v { "1"sv, "2"sv, "3"sv, "4"sv };
|
||||
EXPECT_EQ(DeprecatedString::formatted("{}", v), "[ 1, 2, 3, 4 ]");
|
||||
EXPECT_EQ(ByteString::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 ] ]");
|
||||
Vector<Vector<ByteString>> v { { "1"sv, "2"sv }, { "3"sv, "4"sv } };
|
||||
EXPECT_EQ(ByteString::formatted("{}", v), "[ [ 1, 2 ], [ 3, 4 ] ]");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(format_wchar)
|
||||
{
|
||||
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(ByteString::formatted("{}", L'a'), "a");
|
||||
EXPECT_EQ(ByteString::formatted("{}", L'\U0001F41E'), "\xF0\x9F\x90\x9E");
|
||||
EXPECT_EQ(ByteString::formatted("{:x}", L'a'), "61");
|
||||
EXPECT_EQ(ByteString::formatted("{:x}", L'\U0001F41E'), "1f41e");
|
||||
EXPECT_EQ(ByteString::formatted("{:d}", L'a'), "97");
|
||||
EXPECT_EQ(ByteString::formatted("{:d}", L'\U0001F41E'), "128030");
|
||||
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:6}", L'a'), "a ");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:6d}", L'a'), " 97");
|
||||
EXPECT_EQ(DeprecatedString::formatted("{:#x}", L'\U0001F41E'), "0x1f41e");
|
||||
EXPECT_EQ(ByteString::formatted("{:6}", L'a'), "a ");
|
||||
EXPECT_EQ(ByteString::formatted("{:6d}", L'a'), " 97");
|
||||
EXPECT_EQ(ByteString::formatted("{:#x}", L'\U0001F41E'), "0x1f41e");
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
|
@ -20,7 +20,7 @@ TEST_CASE(construct)
|
|||
|
||||
TEST_CASE(construct_from_initializer_list)
|
||||
{
|
||||
HashMap<int, DeprecatedString> number_to_string {
|
||||
HashMap<int, ByteString> number_to_string {
|
||||
{ 1, "One" },
|
||||
{ 2, "Two" },
|
||||
{ 3, "Three" },
|
||||
|
@ -31,7 +31,7 @@ TEST_CASE(construct_from_initializer_list)
|
|||
|
||||
TEST_CASE(populate)
|
||||
{
|
||||
HashMap<int, DeprecatedString> number_to_string;
|
||||
HashMap<int, ByteString> number_to_string;
|
||||
number_to_string.set(1, "One");
|
||||
number_to_string.set(2, "Two");
|
||||
number_to_string.set(3, "Three");
|
||||
|
@ -42,7 +42,7 @@ TEST_CASE(populate)
|
|||
|
||||
TEST_CASE(range_loop)
|
||||
{
|
||||
HashMap<int, DeprecatedString> number_to_string;
|
||||
HashMap<int, ByteString> 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);
|
||||
|
@ -57,7 +57,7 @@ TEST_CASE(range_loop)
|
|||
|
||||
TEST_CASE(map_remove)
|
||||
{
|
||||
HashMap<int, DeprecatedString> number_to_string;
|
||||
HashMap<int, ByteString> 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);
|
||||
|
@ -74,7 +74,7 @@ TEST_CASE(map_remove)
|
|||
|
||||
TEST_CASE(remove_all_matching)
|
||||
{
|
||||
HashMap<int, DeprecatedString> map;
|
||||
HashMap<int, ByteString> map;
|
||||
|
||||
map.set(1, "One");
|
||||
map.set(2, "Two");
|
||||
|
@ -83,27 +83,27 @@ TEST_CASE(remove_all_matching)
|
|||
|
||||
EXPECT_EQ(map.size(), 4u);
|
||||
|
||||
EXPECT_EQ(map.remove_all_matching([&](int key, DeprecatedString const& value) { return key == 1 || value == "Two"; }), true);
|
||||
EXPECT_EQ(map.remove_all_matching([&](int key, ByteString const& value) { return key == 1 || value == "Two"; }), true);
|
||||
EXPECT_EQ(map.size(), 2u);
|
||||
|
||||
EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return false; }), false);
|
||||
EXPECT_EQ(map.remove_all_matching([&](int, ByteString const&) { return false; }), false);
|
||||
EXPECT_EQ(map.size(), 2u);
|
||||
|
||||
EXPECT(map.contains(3));
|
||||
EXPECT(map.contains(4));
|
||||
|
||||
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_EQ(map.remove_all_matching([&](int, ByteString const&) { return true; }), true);
|
||||
EXPECT_EQ(map.remove_all_matching([&](int, ByteString const&) { return false; }), false);
|
||||
|
||||
EXPECT(map.is_empty());
|
||||
|
||||
EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return true; }), false);
|
||||
EXPECT_EQ(map.remove_all_matching([&](int, ByteString const&) { return true; }), false);
|
||||
}
|
||||
|
||||
TEST_CASE(case_insensitive)
|
||||
{
|
||||
HashMap<DeprecatedString, int, CaseInsensitiveStringTraits> casemap;
|
||||
EXPECT_EQ(DeprecatedString("nickserv").to_lowercase(), DeprecatedString("NickServ").to_lowercase());
|
||||
HashMap<ByteString, int, CaseInsensitiveStringTraits> casemap;
|
||||
EXPECT_EQ(ByteString("nickserv").to_lowercase(), ByteString("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);
|
||||
|
@ -120,11 +120,11 @@ TEST_CASE(case_insensitive_stringview)
|
|||
TEST_CASE(hashmap_of_nonnullownptr_get)
|
||||
{
|
||||
struct Object {
|
||||
Object(DeprecatedString const& s)
|
||||
Object(ByteString const& s)
|
||||
: string(s)
|
||||
{
|
||||
}
|
||||
DeprecatedString string;
|
||||
ByteString string;
|
||||
};
|
||||
|
||||
HashMap<int, NonnullOwnPtr<Object>> objects;
|
||||
|
@ -151,16 +151,16 @@ TEST_CASE(hashmap_of_nonnullownptr_get)
|
|||
|
||||
TEST_CASE(many_strings)
|
||||
{
|
||||
HashMap<DeprecatedString, int> strings;
|
||||
HashMap<ByteString, int> strings;
|
||||
for (int i = 0; i < 999; ++i) {
|
||||
EXPECT_EQ(strings.set(DeprecatedString::number(i), i), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(strings.set(ByteString::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(DeprecatedString::number(i)), true);
|
||||
EXPECT_EQ(strings.remove(ByteString::number(i)), true);
|
||||
}
|
||||
EXPECT_EQ(strings.is_empty(), true);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ TEST_CASE(basic_contains)
|
|||
|
||||
TEST_CASE(in_place_rehashing_ordered_loop_bug)
|
||||
{
|
||||
OrderedHashMap<DeprecatedString, DeprecatedString> map;
|
||||
OrderedHashMap<ByteString, ByteString> map;
|
||||
map.set("yt.innertube::nextId", "");
|
||||
map.set("yt.innertube::requests", "");
|
||||
map.remove("yt.innertube::nextId");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -46,7 +46,7 @@ TEST_CASE(move_is_not_swap)
|
|||
|
||||
TEST_CASE(populate)
|
||||
{
|
||||
HashTable<DeprecatedString> strings;
|
||||
HashTable<ByteString> strings;
|
||||
strings.set("One");
|
||||
strings.set("Two");
|
||||
strings.set("Three");
|
||||
|
@ -57,7 +57,7 @@ TEST_CASE(populate)
|
|||
|
||||
TEST_CASE(range_loop)
|
||||
{
|
||||
HashTable<DeprecatedString> strings;
|
||||
HashTable<ByteString> 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);
|
||||
|
@ -73,7 +73,7 @@ TEST_CASE(range_loop)
|
|||
TEST_CASE(range_loop_reverse)
|
||||
{
|
||||
Array strings = { "One"sv, "Two"sv, "Three"sv };
|
||||
OrderedHashTable<DeprecatedString> table;
|
||||
OrderedHashTable<ByteString> table;
|
||||
EXPECT_EQ(table.set(strings[0]), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(table.set(strings[1]), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(table.set(strings[2]), AK::HashSetResult::InsertedNewEntry);
|
||||
|
@ -90,7 +90,7 @@ TEST_CASE(range_loop_reverse)
|
|||
|
||||
TEST_CASE(table_remove)
|
||||
{
|
||||
HashTable<DeprecatedString> strings;
|
||||
HashTable<ByteString> 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);
|
||||
|
@ -133,8 +133,8 @@ TEST_CASE(remove_all_matching)
|
|||
|
||||
TEST_CASE(case_insensitive)
|
||||
{
|
||||
HashTable<DeprecatedString, CaseInsensitiveStringTraits> casetable;
|
||||
EXPECT_EQ(DeprecatedString("nickserv").to_lowercase(), DeprecatedString("NickServ").to_lowercase());
|
||||
HashTable<ByteString, CaseInsensitiveStringTraits> casetable;
|
||||
EXPECT_EQ(ByteString("nickserv").to_lowercase(), ByteString("NickServ").to_lowercase());
|
||||
EXPECT_EQ(casetable.set("nickserv"), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(casetable.set("NickServ"), AK::HashSetResult::ReplacedExistingEntry);
|
||||
EXPECT_EQ(casetable.size(), 1u);
|
||||
|
@ -142,33 +142,33 @@ TEST_CASE(case_insensitive)
|
|||
|
||||
TEST_CASE(many_strings)
|
||||
{
|
||||
HashTable<DeprecatedString> strings;
|
||||
HashTable<ByteString> strings;
|
||||
for (int i = 0; i < 999; ++i) {
|
||||
EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(strings.set(ByteString::number(i)), AK::HashSetResult::InsertedNewEntry);
|
||||
}
|
||||
EXPECT_EQ(strings.size(), 999u);
|
||||
for (int i = 0; i < 999; ++i) {
|
||||
EXPECT_EQ(strings.remove(DeprecatedString::number(i)), true);
|
||||
EXPECT_EQ(strings.remove(ByteString::number(i)), true);
|
||||
}
|
||||
EXPECT_EQ(strings.is_empty(), true);
|
||||
}
|
||||
|
||||
TEST_CASE(many_collisions)
|
||||
{
|
||||
struct StringCollisionTraits : public DefaultTraits<DeprecatedString> {
|
||||
static unsigned hash(DeprecatedString const&) { return 0; }
|
||||
struct StringCollisionTraits : public DefaultTraits<ByteString> {
|
||||
static unsigned hash(ByteString const&) { return 0; }
|
||||
};
|
||||
|
||||
HashTable<DeprecatedString, StringCollisionTraits> strings;
|
||||
HashTable<ByteString, StringCollisionTraits> strings;
|
||||
for (int i = 0; i < 999; ++i) {
|
||||
EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(strings.set(ByteString::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(DeprecatedString::number(i)), true);
|
||||
EXPECT_EQ(strings.remove(ByteString::number(i)), true);
|
||||
}
|
||||
|
||||
EXPECT(strings.find("foo") != strings.end());
|
||||
|
@ -176,24 +176,24 @@ TEST_CASE(many_collisions)
|
|||
|
||||
TEST_CASE(space_reuse)
|
||||
{
|
||||
struct StringCollisionTraits : public DefaultTraits<DeprecatedString> {
|
||||
static unsigned hash(DeprecatedString const&) { return 0; }
|
||||
struct StringCollisionTraits : public DefaultTraits<ByteString> {
|
||||
static unsigned hash(ByteString const&) { return 0; }
|
||||
};
|
||||
|
||||
HashTable<DeprecatedString, StringCollisionTraits> strings;
|
||||
HashTable<ByteString, 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(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(strings.remove(DeprecatedString::number(i - 1)), true);
|
||||
EXPECT_EQ(strings.set(ByteString::number(i)), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(strings.remove(ByteString::number(i - 1)), true);
|
||||
}
|
||||
|
||||
auto capacity = strings.capacity();
|
||||
|
||||
for (int i = 5; i < 999; ++i) {
|
||||
EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(strings.remove(DeprecatedString::number(i - 1)), true);
|
||||
EXPECT_EQ(strings.set(ByteString::number(i)), AK::HashSetResult::InsertedNewEntry);
|
||||
EXPECT_EQ(strings.remove(ByteString::number(i - 1)), true);
|
||||
}
|
||||
|
||||
EXPECT_EQ(strings.capacity(), capacity);
|
||||
|
@ -301,7 +301,7 @@ TEST_CASE(doubles)
|
|||
|
||||
TEST_CASE(reinsertion)
|
||||
{
|
||||
OrderedHashTable<DeprecatedString> map;
|
||||
OrderedHashTable<ByteString> map;
|
||||
map.set("ytidb::LAST_RESULT_ENTRY_KEY");
|
||||
map.set("__sak");
|
||||
map.remove("__sak");
|
||||
|
@ -445,7 +445,7 @@ TEST_CASE(ordered_remove_from_head)
|
|||
|
||||
TEST_CASE(ordered_infinite_loop_clang_regression)
|
||||
{
|
||||
OrderedHashTable<DeprecatedString> map;
|
||||
OrderedHashTable<ByteString> map;
|
||||
map.set("");
|
||||
map.set("1");
|
||||
map.set("_cb");
|
||||
|
|
|
@ -61,7 +61,7 @@ TEST_CASE(should_convert_to_string)
|
|||
{
|
||||
constexpr IPv4Address addr(1, 25, 39, 42);
|
||||
|
||||
EXPECT_EQ("1.25.39.42", addr.to_deprecated_string());
|
||||
EXPECT_EQ("1.25.39.42", addr.to_byte_string());
|
||||
}
|
||||
|
||||
TEST_CASE(should_make_ipv4_address_from_string)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonValue.h>
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
TEST_CASE(load_form)
|
||||
{
|
||||
DeprecatedString raw_form_json = R"(
|
||||
ByteString raw_form_json = R"(
|
||||
{
|
||||
"name": "Form1",
|
||||
"widgets": [
|
||||
|
@ -40,7 +40,7 @@ TEST_CASE(load_form)
|
|||
|
||||
EXPECT(form_json.is_object());
|
||||
|
||||
auto name = form_json.as_object().get_deprecated_string("name"sv);
|
||||
auto name = form_json.as_object().get_byte_string("name"sv);
|
||||
EXPECT(name.has_value());
|
||||
|
||||
EXPECT_EQ(name.value(), "Form1");
|
||||
|
@ -50,7 +50,7 @@ TEST_CASE(load_form)
|
|||
|
||||
widgets->for_each([&](JsonValue const& widget_value) {
|
||||
auto& widget_object = widget_value.as_object();
|
||||
auto widget_class = widget_object.get_deprecated_string("class"sv).value();
|
||||
auto widget_class = widget_object.get_byte_string("class"sv).value();
|
||||
widget_object.for_each_member([&]([[maybe_unused]] auto& property_name, [[maybe_unused]] const JsonValue& property_value) {
|
||||
});
|
||||
});
|
||||
|
@ -109,13 +109,13 @@ TEST_CASE(json_duplicate_keys)
|
|||
json.set("test", "foo");
|
||||
json.set("test", "bar");
|
||||
json.set("test", "baz");
|
||||
EXPECT_EQ(json.to_deprecated_string(), "{\"test\":\"baz\"}");
|
||||
EXPECT_EQ(json.to_byte_string(), "{\"test\":\"baz\"}");
|
||||
}
|
||||
|
||||
TEST_CASE(json_u64_roundtrip)
|
||||
{
|
||||
auto big_value = 0xffffffffffffffffull;
|
||||
auto json = JsonValue(big_value).to_deprecated_string();
|
||||
auto json = JsonValue(big_value).to_byte_string();
|
||||
auto value = JsonValue::from_string(json);
|
||||
EXPECT_EQ_FORCE(value.is_error(), false);
|
||||
EXPECT_EQ(value.value().as_u64(), big_value);
|
||||
|
@ -292,7 +292,7 @@ private:
|
|||
|
||||
TEST_CASE(fallible_json_object_for_each)
|
||||
{
|
||||
DeprecatedString raw_json = R"(
|
||||
ByteString raw_json = R"(
|
||||
{
|
||||
"name": "anon",
|
||||
"home": "/home/anon",
|
||||
|
@ -332,7 +332,7 @@ TEST_CASE(fallible_json_object_for_each)
|
|||
|
||||
TEST_CASE(fallible_json_array_for_each)
|
||||
{
|
||||
DeprecatedString raw_json = R"(
|
||||
ByteString raw_json = R"(
|
||||
[
|
||||
"anon",
|
||||
"/home/anon",
|
||||
|
@ -489,7 +489,7 @@ TEST_CASE(json_array_serialize)
|
|||
auto array = json_value.as_array();
|
||||
StringBuilder builder {};
|
||||
array.serialize(builder);
|
||||
EXPECT_EQ(builder.to_deprecated_string(), raw_json);
|
||||
EXPECT_EQ(builder.to_byte_string(), raw_json);
|
||||
}
|
||||
|
||||
TEST_CASE(json_array_values)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
|
||||
TEST_CASE(relative_path)
|
||||
|
|
|
@ -80,7 +80,7 @@ TEST_CASE(should_equality_compare)
|
|||
TEST_CASE(should_string_format)
|
||||
{
|
||||
MACAddress sut(1, 2, 3, 4, 5, 6);
|
||||
EXPECT_EQ("01:02:03:04:05:06", sut.to_deprecated_string());
|
||||
EXPECT_EQ("01:02:03:04:05:06", sut.to_byte_string());
|
||||
}
|
||||
|
||||
TEST_CASE(should_make_mac_address_from_string_numbers)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/MemMem.h>
|
||||
#include <AK/Memory.h>
|
||||
|
||||
|
@ -78,9 +78,9 @@ TEST_CASE(kmp_two_chunks)
|
|||
|
||||
TEST_CASE(timing_safe_compare)
|
||||
{
|
||||
DeprecatedString data_set = "abcdefghijklmnopqrstuvwxyz123456789";
|
||||
ByteString data_set = "abcdefghijklmnopqrstuvwxyz123456789";
|
||||
EXPECT_EQ(true, AK::timing_safe_compare(data_set.characters(), data_set.characters(), data_set.length()));
|
||||
|
||||
DeprecatedString reversed = data_set.reverse();
|
||||
ByteString reversed = data_set.reverse();
|
||||
EXPECT_EQ(false, AK::timing_safe_compare(data_set.characters(), reversed.characters(), reversed.length()));
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
|
@ -59,7 +59,7 @@ TEST_CASE(optional_rvalue_ref_qualified_getters)
|
|||
TEST_CASE(optional_leak_1)
|
||||
{
|
||||
struct Structure {
|
||||
Optional<DeprecatedString> str;
|
||||
Optional<ByteString> 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<DeprecatedString> opt2;
|
||||
Optional<ByteString> 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<DeprecatedString> opt2 = "foo"sv;
|
||||
Optional<ByteString> 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<DeprecatedString> opt0;
|
||||
EXPECT_NE(opt0, DeprecatedString());
|
||||
Optional<ByteString> opt0;
|
||||
EXPECT_NE(opt0, ByteString());
|
||||
EXPECT_NE(opt0, "foo");
|
||||
|
||||
Optional<StringView> opt1 = "foo"sv;
|
||||
EXPECT_EQ(opt1, "foo");
|
||||
EXPECT_NE(opt1, "bar");
|
||||
EXPECT_EQ(opt1, DeprecatedString("foo"));
|
||||
EXPECT_EQ(opt1, ByteString("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<DeprecatedString> opt2 = "foo"sv;
|
||||
Optional<ByteString> opt2 = "foo"sv;
|
||||
Optional<StringView> opt3 = "bar"sv;
|
||||
|
||||
EXPECT_NE(opt0, opt1);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Queue.h>
|
||||
|
||||
TEST_CASE(construct)
|
||||
|
@ -32,7 +32,7 @@ TEST_CASE(populate_int)
|
|||
|
||||
TEST_CASE(populate_string)
|
||||
{
|
||||
Queue<DeprecatedString> strings;
|
||||
Queue<ByteString> strings;
|
||||
strings.enqueue("ABC");
|
||||
strings.enqueue("DEF");
|
||||
EXPECT_EQ(strings.size(), 2u);
|
||||
|
@ -43,11 +43,11 @@ TEST_CASE(populate_string)
|
|||
|
||||
TEST_CASE(order)
|
||||
{
|
||||
Queue<DeprecatedString> strings;
|
||||
Queue<ByteString> strings;
|
||||
EXPECT(strings.is_empty());
|
||||
|
||||
for (size_t i = 0; i < 10000; ++i) {
|
||||
strings.enqueue(DeprecatedString::number(i));
|
||||
strings.enqueue(ByteString::number(i));
|
||||
EXPECT_EQ(strings.size(), i + 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
|
||||
struct Object : public RefCounted<Object> {
|
||||
|
|
|
@ -26,7 +26,7 @@ TEST_CASE(basic)
|
|||
|
||||
TEST_CASE(complex_type)
|
||||
{
|
||||
AK::Stack<DeprecatedString, 4> stack;
|
||||
AK::Stack<ByteString, 4> stack;
|
||||
|
||||
EXPECT_EQ(stack.is_empty(), true);
|
||||
EXPECT(stack.push("Well"));
|
||||
|
|
|
@ -22,11 +22,11 @@ TEST_CASE(hash_compatible)
|
|||
static_assert(AK::Concepts::HashCompatible<FlyString, String>);
|
||||
static_assert(AK::Concepts::HashCompatible<FlyString, StringView>);
|
||||
|
||||
static_assert(AK::Concepts::HashCompatible<DeprecatedString, StringView>);
|
||||
static_assert(AK::Concepts::HashCompatible<DeprecatedString, DeprecatedFlyString>);
|
||||
static_assert(AK::Concepts::HashCompatible<StringView, DeprecatedString>);
|
||||
static_assert(AK::Concepts::HashCompatible<ByteString, StringView>);
|
||||
static_assert(AK::Concepts::HashCompatible<ByteString, DeprecatedFlyString>);
|
||||
static_assert(AK::Concepts::HashCompatible<StringView, ByteString>);
|
||||
static_assert(AK::Concepts::HashCompatible<StringView, DeprecatedFlyString>);
|
||||
static_assert(AK::Concepts::HashCompatible<DeprecatedFlyString, DeprecatedString>);
|
||||
static_assert(AK::Concepts::HashCompatible<DeprecatedFlyString, ByteString>);
|
||||
static_assert(AK::Concepts::HashCompatible<DeprecatedFlyString, StringView>);
|
||||
|
||||
static_assert(AK::Concepts::HashCompatible<StringView, ByteBuffer>);
|
||||
|
@ -328,7 +328,7 @@ TEST_CASE(convert_to_floating_point)
|
|||
|
||||
TEST_CASE(ends_with)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString 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));
|
||||
|
@ -339,7 +339,7 @@ TEST_CASE(ends_with)
|
|||
|
||||
TEST_CASE(starts_with)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString 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));
|
||||
|
@ -350,7 +350,7 @@ TEST_CASE(starts_with)
|
|||
|
||||
TEST_CASE(contains)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEFABCXYZ";
|
||||
ByteString 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));
|
||||
|
@ -368,7 +368,7 @@ TEST_CASE(contains)
|
|||
EXPECT(!AK::StringUtils::contains(test_string, "L"sv, CaseSensitivity::CaseSensitive));
|
||||
EXPECT(!AK::StringUtils::contains(test_string, "L"sv, CaseSensitivity::CaseInsensitive));
|
||||
|
||||
DeprecatedString command_palette_bug_string = "Go Go Back";
|
||||
ByteString 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));
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ TEST_CASE(trim)
|
|||
|
||||
TEST_CASE(find)
|
||||
{
|
||||
DeprecatedString test_string = "1234567";
|
||||
ByteString 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);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
TEST_CASE(construct_empty)
|
||||
|
@ -29,8 +29,8 @@ TEST_CASE(view_literal)
|
|||
|
||||
TEST_CASE(compare_views)
|
||||
{
|
||||
DeprecatedString foo1 = "foo";
|
||||
DeprecatedString foo2 = "foo";
|
||||
ByteString foo1 = "foo";
|
||||
ByteString 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;
|
||||
DeprecatedString test_string = "foo";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString test_string = "ABCDEF";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString test_string = "a\rb\nc\r\nd";
|
||||
ByteString 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) == 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"));
|
||||
EXPECT(test_string_vector.at(0) == ByteString("a"));
|
||||
EXPECT(test_string_vector.at(1) == ByteString("b"));
|
||||
EXPECT(test_string_vector.at(2) == ByteString("c"));
|
||||
EXPECT(test_string_vector.at(3) == ByteString("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) == 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("```"));
|
||||
EXPECT(test_string_vector.at(0) == ByteString("```"));
|
||||
EXPECT(test_string_vector.at(1) == ByteString("Hello there"));
|
||||
EXPECT(test_string_vector.at(2) == ByteString("Hello there"));
|
||||
EXPECT(test_string_vector.at(3) == ByteString("```"));
|
||||
|
||||
test_string = "\n\n\n";
|
||||
test_string_view = test_string.view();
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
TEST_CASE(normal_behavior)
|
||||
{
|
||||
Trie<char, DeprecatedString> dictionary('/', "");
|
||||
Trie<char, ByteString> 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<DeprecatedString> { return DeprecatedString::formatted("{}{}", parent.metadata_value(), *it); }));
|
||||
MUST(dictionary.insert(it, view.end(), view, [](auto& parent, auto& it) -> Optional<ByteString> { return ByteString::formatted("{}{}", parent.metadata_value(), *it); }));
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
|
|
|
@ -10,41 +10,41 @@
|
|||
|
||||
TEST_CASE(basic)
|
||||
{
|
||||
Tuple<int, DeprecatedString> value { 1, "foo" };
|
||||
Tuple<int, ByteString> value { 1, "foo" };
|
||||
EXPECT_EQ(value.get<int>(), 1);
|
||||
EXPECT_EQ(value.get<DeprecatedString>(), "foo");
|
||||
EXPECT_EQ(value.get<ByteString>(), "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<DeprecatedString>(), "bar");
|
||||
EXPECT_EQ(value.get<ByteString>(), "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<DeprecatedString>(), "bar");
|
||||
EXPECT_EQ(other_value.get<ByteString>(), "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<DeprecatedString>(), "bar");
|
||||
EXPECT_EQ(moved_to_value.get<ByteString>(), "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<DeprecatedString>(), "bar");
|
||||
EXPECT_EQ(moved_to_value.get<ByteString>(), "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<DeprecatedString>(), "bar");
|
||||
EXPECT_EQ(value.get<ByteString>(), "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, DeprecatedString> args { 1, 2, "foo" };
|
||||
Tuple<int, int, ByteString> args { 1, 2, "foo" };
|
||||
|
||||
// With copy
|
||||
{
|
||||
bool was_called = false;
|
||||
args.apply_as_args([&](int a, int b, DeprecatedString c) {
|
||||
args.apply_as_args([&](int a, int b, ByteString 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, DeprecatedString& c) {
|
||||
args.apply_as_args([&](int& a, int& b, ByteString& 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, DeprecatedString const& c) {
|
||||
args_ref.apply_as_args([&](int const& a, int const& b, ByteString const& c) {
|
||||
was_called = true;
|
||||
EXPECT_EQ(a, 1);
|
||||
EXPECT_EQ(b, 2);
|
||||
|
|
|
@ -412,21 +412,21 @@ TEST_CASE(leading_whitespace)
|
|||
{
|
||||
URL url { " https://foo.com/"sv };
|
||||
EXPECT(url.is_valid());
|
||||
EXPECT_EQ(url.to_deprecated_string(), "https://foo.com/");
|
||||
EXPECT_EQ(url.to_byte_string(), "https://foo.com/");
|
||||
}
|
||||
|
||||
TEST_CASE(trailing_whitespace)
|
||||
{
|
||||
URL url { "https://foo.com/ "sv };
|
||||
EXPECT(url.is_valid());
|
||||
EXPECT_EQ(url.to_deprecated_string(), "https://foo.com/");
|
||||
EXPECT_EQ(url.to_byte_string(), "https://foo.com/");
|
||||
}
|
||||
|
||||
TEST_CASE(leading_and_trailing_whitespace)
|
||||
{
|
||||
URL url { " https://foo.com/ "sv };
|
||||
EXPECT(url.is_valid());
|
||||
EXPECT_EQ(url.to_deprecated_string(), "https://foo.com/");
|
||||
EXPECT_EQ(url.to_byte_string(), "https://foo.com/");
|
||||
}
|
||||
|
||||
TEST_CASE(unicode)
|
||||
|
|
|
@ -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 };
|
||||
DeprecatedString expected_underlying_bytes[] = { "П", "р", "и", "в", "е", "т", ",", " ", "м", "и", "р", "!", " ", "😀", " ", "γ", "ε", "ι", "ά", " ", "σ", "ο", "υ", " ", "κ", "ό", "σ", "μ", "ο", "ς", " ", "こ", "ん", "に", "ち", "は", "世", "界" };
|
||||
ByteString expected_underlying_bytes[] = { "П", "р", "и", "в", "е", "т", ",", " ", "м", "и", "р", "!", " ", "😀", " ", "γ", "ε", "ι", "ά", " ", "σ", "ο", "υ", " ", "κ", "ό", "σ", "μ", "ο", "ς", " ", "こ", "ん", "に", "ち", "は", "世", "界" };
|
||||
size_t expected_size = sizeof(expected) / sizeof(expected[0]);
|
||||
|
||||
size_t i = 0;
|
||||
|
@ -166,7 +166,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' };
|
||||
DeprecatedString expected_underlying_bytes[] = { "a", "b", "\xA0", "d" };
|
||||
ByteString 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) {
|
||||
|
@ -184,7 +184,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' };
|
||||
DeprecatedString expected_underlying_bytes[] = { "a", "b", "\xC0", "d", "e" };
|
||||
ByteString 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) {
|
||||
|
@ -202,7 +202,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' };
|
||||
DeprecatedString expected_underlying_bytes[] = { "a", "b", "\x90", "d" };
|
||||
ByteString 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) {
|
||||
|
@ -220,7 +220,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 };
|
||||
DeprecatedString expected_underlying_bytes[] = { "a", "b", "c", "\x90" };
|
||||
ByteString 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) {
|
||||
|
@ -247,7 +247,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' };
|
||||
DeprecatedString expected_underlying_bytes[] = { "a", "\xF4\xA3\x91\x96", "b" };
|
||||
ByteString 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) {
|
||||
|
|
|
@ -18,21 +18,21 @@ struct Object : public RefCounted<Object> {
|
|||
|
||||
TEST_CASE(basic)
|
||||
{
|
||||
Variant<int, DeprecatedString> the_value { 42 };
|
||||
Variant<int, ByteString> the_value { 42 };
|
||||
EXPECT(the_value.has<int>());
|
||||
EXPECT_EQ(the_value.get<int>(), 42);
|
||||
the_value = DeprecatedString("42");
|
||||
EXPECT(the_value.has<DeprecatedString>());
|
||||
EXPECT_EQ(the_value.get<DeprecatedString>(), "42");
|
||||
the_value = ByteString("42");
|
||||
EXPECT(the_value.has<ByteString>());
|
||||
EXPECT_EQ(the_value.get<ByteString>(), "42");
|
||||
}
|
||||
|
||||
TEST_CASE(visit)
|
||||
{
|
||||
bool correct = false;
|
||||
Variant<int, DeprecatedString, float> the_value { 42.0f };
|
||||
Variant<int, ByteString, float> the_value { 42.0f };
|
||||
the_value.visit(
|
||||
[&](int const&) { correct = false; },
|
||||
[&](DeprecatedString const&) { correct = false; },
|
||||
[&](ByteString 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, DeprecatedString> const the_value { "42"sv };
|
||||
Variant<int, ByteString> const the_value { "42"sv };
|
||||
|
||||
the_value.visit(
|
||||
[&](DeprecatedString const&) { correct = true; },
|
||||
[&](ByteString 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(
|
||||
[&](DeprecatedString const&) { correct = true; },
|
||||
[&](ByteString const&) { correct = true; },
|
||||
[&](auto&) {});
|
||||
|
||||
EXPECT(correct);
|
||||
|
@ -168,13 +168,13 @@ TEST_CASE(duplicated_types)
|
|||
|
||||
TEST_CASE(return_values)
|
||||
{
|
||||
using MyVariant = Variant<int, DeprecatedString, float>;
|
||||
using MyVariant = Variant<int, ByteString, float>;
|
||||
{
|
||||
MyVariant the_value { 42.0f };
|
||||
|
||||
float value = the_value.visit(
|
||||
[&](int const&) { return 1.0f; },
|
||||
[&](DeprecatedString const&) { return 2.0f; },
|
||||
[&](ByteString 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; },
|
||||
[&](DeprecatedString&) { return 2; },
|
||||
[&](ByteString&) { return 2; },
|
||||
[&](float&) { return 3; });
|
||||
EXPECT_EQ(value, 42);
|
||||
}
|
||||
{
|
||||
const MyVariant the_value { "str" };
|
||||
|
||||
DeprecatedString value = the_value.visit(
|
||||
[&](int const&) { return DeprecatedString { "wrong" }; },
|
||||
[&](DeprecatedString const& s) { return s; },
|
||||
[&](float const&) { return DeprecatedString { "wrong" }; });
|
||||
ByteString value = the_value.visit(
|
||||
[&](int const&) { return ByteString { "wrong" }; },
|
||||
[&](ByteString const& s) { return s; },
|
||||
[&](float const&) { return ByteString { "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, DeprecatedString, float> the_value { 42.0f };
|
||||
Variant<int, ByteString, float> the_value { 42.0f };
|
||||
|
||||
auto& value = the_value.visit(
|
||||
[&](int const&) -> RefPtr<Object>& { return ref; },
|
||||
[&](DeprecatedString const&) -> RefPtr<Object>& { return ref; },
|
||||
[&](ByteString 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, DeprecatedString, float> the_value { 42.0f };
|
||||
Variant<int, ByteString, 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 = DeprecatedString("Hello, world!");
|
||||
VERIFY(the_value.has<DeprecatedString>());
|
||||
EXPECT_EQ(the_value.get<DeprecatedString>(), "Hello, world!");
|
||||
the_value = ByteString("Hello, world!");
|
||||
VERIFY(the_value.has<ByteString>());
|
||||
EXPECT_EQ(the_value.get<ByteString>(), "Hello, world!");
|
||||
}
|
||||
{
|
||||
Variant<HoldsInt, DeprecatedString, HoldsFloat> the_value { HoldsFloat { 42.0f } };
|
||||
Variant<HoldsInt, ByteString, 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 = DeprecatedString("Hello, world!");
|
||||
VERIFY(the_value.has<DeprecatedString>());
|
||||
EXPECT_EQ(the_value.get<DeprecatedString>(), "Hello, world!");
|
||||
the_value = ByteString("Hello, world!");
|
||||
VERIFY(the_value.has<ByteString>());
|
||||
EXPECT_EQ(the_value.get<ByteString>(), "Hello, world!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/ReverseIterator.h>
|
||||
#include <AK/String.h>
|
||||
|
@ -38,18 +38,18 @@ TEST_CASE(ints)
|
|||
|
||||
TEST_CASE(strings)
|
||||
{
|
||||
Vector<DeprecatedString> strings;
|
||||
Vector<ByteString> strings;
|
||||
strings.append("ABC");
|
||||
strings.append("DEF");
|
||||
|
||||
int loop_counter = 0;
|
||||
for (DeprecatedString const& string : strings) {
|
||||
for (ByteString const& string : strings) {
|
||||
EXPECT(!string.is_empty());
|
||||
++loop_counter;
|
||||
}
|
||||
|
||||
loop_counter = 0;
|
||||
for (auto& string : (const_cast<Vector<DeprecatedString> const&>(strings))) {
|
||||
for (auto& string : (const_cast<Vector<ByteString> const&>(strings))) {
|
||||
EXPECT(!string.is_empty());
|
||||
++loop_counter;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ TEST_CASE(strings)
|
|||
|
||||
TEST_CASE(strings_insert_ordered)
|
||||
{
|
||||
Vector<DeprecatedString> strings;
|
||||
Vector<ByteString> strings;
|
||||
strings.append("abc");
|
||||
strings.append("def");
|
||||
strings.append("ghi");
|
||||
|
@ -161,12 +161,12 @@ TEST_CASE(vector_compare)
|
|||
EXPECT_EQ(ints.size(), 1000u);
|
||||
EXPECT_EQ(ints, same_ints);
|
||||
|
||||
Vector<DeprecatedString> strings;
|
||||
Vector<DeprecatedString> same_strings;
|
||||
Vector<ByteString> strings;
|
||||
Vector<ByteString> same_strings;
|
||||
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
strings.append(DeprecatedString::number(i));
|
||||
same_strings.append(DeprecatedString::number(i));
|
||||
strings.append(ByteString::number(i));
|
||||
same_strings.append(ByteString::number(i));
|
||||
}
|
||||
|
||||
EXPECT_EQ(strings.size(), 1000u);
|
||||
|
@ -176,9 +176,9 @@ TEST_CASE(vector_compare)
|
|||
TEST_CASE(grow_past_inline_capacity)
|
||||
{
|
||||
auto make_vector = [] {
|
||||
Vector<DeprecatedString, 16> strings;
|
||||
Vector<ByteString, 16> strings;
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
strings.append(DeprecatedString::number(i));
|
||||
strings.append(ByteString::number(i));
|
||||
}
|
||||
return strings;
|
||||
};
|
||||
|
@ -284,7 +284,7 @@ TEST_CASE(remove_all_matching)
|
|||
TEST_CASE(nonnullownptrvector)
|
||||
{
|
||||
struct Object {
|
||||
DeprecatedString string;
|
||||
ByteString string;
|
||||
};
|
||||
Vector<NonnullOwnPtr<Object>> objects;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <AK/Weakable.h>
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ static const LexicalPath path_to_compiler_binary = [] {
|
|||
}();
|
||||
static const LexicalPath path_to_tests_directory { relative_path_to_test };
|
||||
|
||||
Vector<DeprecatedString> build_command_line_arguments(LexicalPath const& test_source, TestDescription const& description)
|
||||
Vector<ByteString> build_command_line_arguments(LexicalPath const& test_source, TestDescription const& description)
|
||||
{
|
||||
Vector<DeprecatedString> result;
|
||||
Vector<ByteString> result;
|
||||
|
||||
StringBuilder dump_ast_option;
|
||||
StringBuilder dump_cfg_option;
|
||||
|
@ -69,9 +69,9 @@ Vector<DeprecatedString> build_command_line_arguments(LexicalPath const& test_so
|
|||
}
|
||||
}
|
||||
if (!dump_ast_option.is_empty())
|
||||
result.append(DeprecatedString::formatted("--dump-ast={}", dump_ast_option.string_view()));
|
||||
result.append(ByteString::formatted("--dump-ast={}", dump_ast_option.string_view()));
|
||||
if (!dump_cfg_option.is_empty())
|
||||
result.append(DeprecatedString::formatted("--dump-cfg={}", dump_cfg_option.string_view()));
|
||||
result.append(ByteString::formatted("--dump-cfg={}", dump_cfg_option.string_view()));
|
||||
|
||||
if (test_source.has_extension(".cpp"sv))
|
||||
result.append("-xc++"sv);
|
||||
|
@ -149,7 +149,7 @@ TEST_CASE(test_regression)
|
|||
dbgln("Running {}...", source);
|
||||
|
||||
auto path_to_test = LexicalPath::join(path_to_tests_directory.string(), source);
|
||||
auto path_to_expectation = LexicalPath::join(path_to_tests_directory.string(), DeprecatedString::formatted("{}.expectation", source));
|
||||
auto path_to_expectation = LexicalPath::join(path_to_tests_directory.string(), ByteString::formatted("{}.expectation", source));
|
||||
|
||||
auto process = MUST(Core::Process::spawn({
|
||||
.path = path_to_compiler_binary.string(),
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -81,11 +81,11 @@ TEST_CASE(test_change_file_location)
|
|||
ftruncate(fd, 0);
|
||||
EXPECT(fchmod(fd, 06755) != -1);
|
||||
|
||||
auto suid_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto suid_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
|
||||
auto suid_path = suid_path_string.to_deprecated_string();
|
||||
auto suid_path = suid_path_string.to_byte_string();
|
||||
EXPECT(suid_path.characters());
|
||||
auto new_path = DeprecatedString::formatted("{}.renamed", suid_path);
|
||||
auto new_path = ByteString::formatted("{}.renamed", suid_path);
|
||||
|
||||
rename(suid_path.characters(), new_path.characters());
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.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 = DeprecatedString::repeated('a', 2048);
|
||||
auto const long_argument = ByteString::repeated('a', 2048);
|
||||
|
||||
auto res = pledge(long_argument.characters(), "stdio");
|
||||
EXPECT_EQ(res, -1);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Function.h>
|
||||
#if ARCH(X86_64)
|
||||
# include <Kernel/Arch/x86_64/IO.h>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Random.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
@ -101,7 +101,7 @@ static void do_weird_call(size_t attempt, int syscall_fn, size_t arg1, size_t ar
|
|||
builder.appendff("{:p}", fake_params[i]);
|
||||
}
|
||||
builder.append(']');
|
||||
dbgln("{}", builder.to_deprecated_string());
|
||||
dbgln("{}", builder.to_byte_string());
|
||||
|
||||
// Actually do the syscall ('fake_params' is passed indirectly, if any of arg1, arg2, or arg3 point to it.
|
||||
int rc = syscall(Syscall::Function(syscall_fn), arg1, arg2, arg3);
|
||||
|
|
|
@ -18,7 +18,7 @@ int main(int argc, char** argv)
|
|||
for (auto i = 0; i < argc; ++i)
|
||||
arguments.append({ argv[i], strlen(argv[i]) });
|
||||
|
||||
DeprecatedString target;
|
||||
ByteString target;
|
||||
int max_file_size = 1024 * 1024;
|
||||
int count = 1024;
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ int main(int argc, char** argv)
|
|||
for (auto i = 0; i < argc; ++i)
|
||||
arguments.append({ argv[i], strlen(argv[i]) });
|
||||
|
||||
DeprecatedString target;
|
||||
ByteString target;
|
||||
int min_block_offset = 0;
|
||||
int block_length = 2048;
|
||||
int block_size = 512;
|
||||
|
|
|
@ -17,21 +17,21 @@ struct DiscoverFLACTestsHack {
|
|||
auto path = LexicalPath::join(directory.path().string(), entry.name);
|
||||
if (path.extension() == "flac"sv) {
|
||||
Test::add_test_case_to_suite(adopt_ref(*new ::Test::TestCase(
|
||||
DeprecatedString::formatted("flac_spec_test_{}", path.basename()),
|
||||
ByteString::formatted("flac_spec_test_{}", path.basename()),
|
||||
[path = move(path)]() {
|
||||
auto file = Core::File::open(path.string(), Core::File::OpenMode::Read);
|
||||
if (file.is_error()) {
|
||||
FAIL(DeprecatedString::formatted("{}", file.error()));
|
||||
FAIL(ByteString::formatted("{}", file.error()));
|
||||
return;
|
||||
}
|
||||
auto buffered_file = Core::InputBufferedFile::create(file.release_value());
|
||||
if (buffered_file.is_error()) {
|
||||
FAIL(DeprecatedString::formatted("{}", buffered_file.error()));
|
||||
FAIL(ByteString::formatted("{}", buffered_file.error()));
|
||||
return;
|
||||
}
|
||||
auto result = Audio::FlacLoaderPlugin::create(buffered_file.release_value());
|
||||
if (result.is_error()) {
|
||||
FAIL(DeprecatedString::formatted("{}", result.error()));
|
||||
FAIL(ByteString::formatted("{}", result.error()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ struct DiscoverFLACTestsHack {
|
|||
while (true) {
|
||||
auto maybe_samples = loader->load_chunks(2 * MiB);
|
||||
if (maybe_samples.is_error()) {
|
||||
FAIL(DeprecatedString::formatted("{}", maybe_samples.error()));
|
||||
FAIL(ByteString::formatted("{}", maybe_samples.error()));
|
||||
return;
|
||||
}
|
||||
maybe_samples.value().remove_all_matching([](auto& chunk) { return chunk.is_empty(); });
|
||||
|
|
|
@ -23,12 +23,12 @@ static int read_event(int fd)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static DeprecatedString get_event_name()
|
||||
static ByteString get_event_name()
|
||||
{
|
||||
if (event->name_length == 0)
|
||||
return DeprecatedString();
|
||||
return ByteString();
|
||||
|
||||
return DeprecatedString { event->name, event->name_length - 1 };
|
||||
return ByteString { event->name, event->name_length - 1 };
|
||||
}
|
||||
|
||||
TEST_CASE(inode_watcher_metadata_modified_event)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <LibFileSystem/FileSystem.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 = DeprecatedString::formatted("{}", mktemp(path));
|
||||
auto temp_path = ByteString::formatted("{}", mktemp(path));
|
||||
EXPECT(temp_path.characters());
|
||||
unlink(path);
|
||||
|
||||
|
@ -33,10 +33,10 @@ TEST_CASE(test_mktemp_unique_filename)
|
|||
} else {
|
||||
wait(NULL);
|
||||
|
||||
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
auto path1 = ByteString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
|
||||
char path[] = "/tmp/test.mktemp.XXXXXX";
|
||||
auto path2 = DeprecatedString::formatted("{}", mktemp(path));
|
||||
auto path2 = ByteString::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 = DeprecatedString::formatted("{}", mkdtemp(path));
|
||||
auto temp_path = ByteString::formatted("{}", mkdtemp(path));
|
||||
EXPECT(temp_path.characters());
|
||||
rmdir(path);
|
||||
|
||||
|
@ -63,10 +63,10 @@ TEST_CASE(test_mkdtemp_unique_filename)
|
|||
} else {
|
||||
wait(NULL);
|
||||
|
||||
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
auto path1 = ByteString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
|
||||
char path[] = "/tmp/test.mkdtemp.XXXXXX";
|
||||
auto path2 = DeprecatedString::formatted("{}", mkdtemp(path));
|
||||
auto path2 = ByteString::formatted("{}", mkdtemp(path));
|
||||
EXPECT(path2.characters());
|
||||
rmdir(path);
|
||||
|
||||
|
@ -86,8 +86,8 @@ TEST_CASE(test_mkstemp_unique_filename)
|
|||
auto fd = mkstemp(path);
|
||||
EXPECT_NE(fd, -1);
|
||||
|
||||
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto temp_path = temp_path_string.to_deprecated_string();
|
||||
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto temp_path = temp_path_string.to_byte_string();
|
||||
EXPECT(temp_path.characters());
|
||||
|
||||
close(fd);
|
||||
|
@ -99,14 +99,14 @@ TEST_CASE(test_mkstemp_unique_filename)
|
|||
} else {
|
||||
wait(NULL);
|
||||
|
||||
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
auto path1 = ByteString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
|
||||
char path[] = "/tmp/test.mkstemp.XXXXXX";
|
||||
auto fd = mkstemp(path);
|
||||
EXPECT(fd != -1);
|
||||
|
||||
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto path2 = path2_string.to_deprecated_string();
|
||||
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto path2 = path2_string.to_byte_string();
|
||||
EXPECT(path2.characters());
|
||||
|
||||
close(fd);
|
||||
|
@ -128,8 +128,8 @@ TEST_CASE(test_mkstemps_unique_filename)
|
|||
auto fd = mkstemps(path, 6);
|
||||
EXPECT_NE(fd, -1);
|
||||
|
||||
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto temp_path = temp_path_string.to_deprecated_string();
|
||||
auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto temp_path = temp_path_string.to_byte_string();
|
||||
EXPECT(temp_path.characters());
|
||||
|
||||
close(fd);
|
||||
|
@ -145,14 +145,14 @@ TEST_CASE(test_mkstemps_unique_filename)
|
|||
} else {
|
||||
wait(NULL);
|
||||
|
||||
auto path1 = DeprecatedString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
auto path1 = ByteString::formatted("{}", reinterpret_cast<char const*>(ptr));
|
||||
|
||||
char path[] = "/tmp/test.mkstemps.prefixXXXXXXsuffix";
|
||||
auto fd = mkstemps(path, 6);
|
||||
EXPECT(fd != -1);
|
||||
|
||||
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto path2 = path2_string.to_deprecated_string();
|
||||
auto path2_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto path2 = path2_string.to_byte_string();
|
||||
EXPECT(path2.characters());
|
||||
|
||||
close(fd);
|
||||
|
|
|
@ -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(DeprecatedString::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result));
|
||||
FAIL(ByteString::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result));
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static DeprecatedString random_dirname()
|
||||
static ByteString random_dirname()
|
||||
{
|
||||
return DeprecatedString::formatted("/tmp/test_mkdir_{:04x}", (u16)rand());
|
||||
return ByteString::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 = DeprecatedString::formatted("{}/foo", parent);
|
||||
auto child = ByteString::formatted("{}/foo", parent);
|
||||
int res = mkdir(child.characters(), 0755);
|
||||
int cached_errno = errno;
|
||||
EXPECT(res < 0);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <pwd.h>
|
||||
|
||||
struct PasswdEntry {
|
||||
DeprecatedString name;
|
||||
ByteString name;
|
||||
uid_t uid {};
|
||||
};
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/Random.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -54,7 +54,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(DeprecatedString::formatted("saw key {} before key {}\n", key1, key2));
|
||||
FAIL(ByteString::formatted("saw key {} before key {}\n", key1, key2));
|
||||
}
|
||||
}
|
||||
// Check that the object's payloads have not been corrupted
|
||||
|
@ -62,7 +62,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(DeprecatedString::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload));
|
||||
FAIL(ByteString::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
@ -24,7 +24,7 @@ static constexpr size_t ITERATION_DEPTH = 17;
|
|||
static void check_result(char const* what, StringView expected, char const* actual)
|
||||
{
|
||||
if (expected != actual)
|
||||
FAIL(DeprecatedString::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0));
|
||||
FAIL(ByteString::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0));
|
||||
}
|
||||
|
||||
TEST_CASE(overlong_realpath)
|
||||
|
@ -50,7 +50,7 @@ TEST_CASE(overlong_realpath)
|
|||
expected.append({ tmp_dir, strlen(tmp_dir) });
|
||||
|
||||
// But first, demonstrate the functionality at a reasonable depth:
|
||||
auto expected_str = expected.to_deprecated_string();
|
||||
auto expected_str = expected.to_byte_string();
|
||||
check_result("getwd", expected_str, getwd(static_cast<char*>(calloc(1, PATH_MAX))));
|
||||
check_result("getcwd", expected_str, getcwd(nullptr, 0));
|
||||
check_result("realpath", expected_str, realpath(".", nullptr));
|
||||
|
@ -59,7 +59,7 @@ TEST_CASE(overlong_realpath)
|
|||
ret = mkdir(PATH_LOREM_250, S_IRWXU);
|
||||
if (ret < 0) {
|
||||
perror("mkdir iter");
|
||||
FAIL(DeprecatedString::formatted("Unable to mkdir the overlong path fragment in iteration {}", i));
|
||||
FAIL(ByteString::formatted("Unable to mkdir the overlong path fragment in iteration {}", i));
|
||||
return;
|
||||
}
|
||||
expected.append('/');
|
||||
|
@ -67,14 +67,14 @@ TEST_CASE(overlong_realpath)
|
|||
ret = chdir(PATH_LOREM_250);
|
||||
if (ret < 0) {
|
||||
perror("chdir iter");
|
||||
FAIL(DeprecatedString::formatted("Unable to chdir to the overlong path fragment in iteration {}", i));
|
||||
FAIL(ByteString::formatted("Unable to chdir to the overlong path fragment in iteration {}", i));
|
||||
return;
|
||||
}
|
||||
}
|
||||
outln("cwd should now be ridiculously large");
|
||||
|
||||
// Evaluate
|
||||
expected_str = expected.to_deprecated_string();
|
||||
expected_str = expected.to_byte_string();
|
||||
|
||||
check_result("getwd", {}, getwd(static_cast<char*>(calloc(1, PATH_MAX))));
|
||||
check_result("getcwd", expected_str, getcwd(nullptr, 0));
|
||||
|
|
|
@ -165,7 +165,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(DeprecatedString::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.",
|
||||
FAIL(ByteString::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.",
|
||||
tests[count].node, U8(tests[count].order), tests[count].depth));
|
||||
}
|
||||
return;
|
||||
|
@ -173,7 +173,7 @@ void twalk_action(void const* node, VISIT order, int depth)
|
|||
|
||||
// Special case: End marker reached.
|
||||
if (tests[count].depth == TWALK_END_MARKER) {
|
||||
FAIL(DeprecatedString::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).",
|
||||
FAIL(ByteString::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).",
|
||||
node, U8(order), depth));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ struct Testcase {
|
|||
size_t dest_expected_n; // == dest_n
|
||||
};
|
||||
|
||||
static DeprecatedString show(ByteBuffer const& buf)
|
||||
static ByteString show(ByteBuffer const& buf)
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < buf.size(); ++i) {
|
||||
|
@ -43,7 +43,7 @@ static DeprecatedString show(ByteBuffer const& buf)
|
|||
builder.append('_');
|
||||
}
|
||||
builder.append(')');
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
template<typename TArg>
|
||||
|
|
|
@ -22,7 +22,7 @@ struct Testcase {
|
|||
size_t dest_expected_n; // == dest_n
|
||||
};
|
||||
|
||||
static DeprecatedString show(ByteBuffer const& buf)
|
||||
static ByteString show(ByteBuffer const& buf)
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < buf.size(); ++i) {
|
||||
|
@ -37,7 +37,7 @@ static DeprecatedString show(ByteBuffer const& buf)
|
|||
builder.append('_');
|
||||
}
|
||||
builder.append(')');
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
static bool test_single(Testcase const& testcase)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.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(DeprecatedString::formatted("\n!!! Encountered char {:02x} at {}", ch, i));
|
||||
FAIL(ByteString::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(DeprecatedString::formatted("{} strtod tests failed", fails));
|
||||
FAIL(ByteString::formatted("{} strtod tests failed", fails));
|
||||
}
|
||||
|
||||
outln("PASS (with leniency up to {} ULP from the exact solution)", LENIENCY);
|
||||
|
|
|
@ -215,7 +215,7 @@ TEST_CASE(mbsinit)
|
|||
size_t ret = mbrtowc(nullptr, "\xdf", 1, &state);
|
||||
|
||||
if (ret != -2ul)
|
||||
FAIL(DeprecatedString::formatted("mbrtowc accepted partial multibyte sequence with return code {} (expected -2)", static_cast<ssize_t>(ret)));
|
||||
FAIL(ByteString::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(DeprecatedString::formatted("mbrtowc did not consume the expected number of bytes (1), returned {} instead", static_cast<ssize_t>(ret)));
|
||||
FAIL(ByteString::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);
|
||||
|
|
|
@ -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
|
||||
DeprecatedString path = DeprecatedString::formatted("/usr/Tests/LibCompress/brotli-test-files/{}", file_name);
|
||||
ByteString path = ByteString::formatted("/usr/Tests/LibCompress/brotli-test-files/{}", file_name);
|
||||
#else
|
||||
DeprecatedString path = DeprecatedString::formatted("brotli-test-files/{}", file_name);
|
||||
ByteString path = ByteString::formatted("brotli-test-files/{}", file_name);
|
||||
#endif
|
||||
|
||||
auto cmp_file = MUST(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
auto cmp_data = MUST(cmp_file->read_until_eof());
|
||||
|
||||
DeprecatedString path_compressed = DeprecatedString::formatted("{}.br", path);
|
||||
ByteString path_compressed = ByteString::formatted("{}.br", path);
|
||||
|
||||
auto file = MUST(Core::File::open(path_compressed, Core::File::OpenMode::Read));
|
||||
auto brotli_stream = Compress::BrotliDecompressionStream { MaybeOwned<Stream> { *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
|
||||
DeprecatedString path = "/usr/Tests/LibCompress/brotli-test-files/zero-one.bin";
|
||||
ByteString path = "/usr/Tests/LibCompress/brotli-test-files/zero-one.bin";
|
||||
#else
|
||||
DeprecatedString path = "brotli-test-files/zero-one.bin";
|
||||
ByteString path = "brotli-test-files/zero-one.bin";
|
||||
#endif
|
||||
|
||||
DeprecatedString path_compressed = DeprecatedString::formatted("{}.br", path);
|
||||
ByteString path_compressed = ByteString::formatted("{}.br", path);
|
||||
|
||||
auto file = MUST(Core::File::open(path_compressed, Core::File::OpenMode::Read));
|
||||
auto brotli_stream = Compress::BrotliDecompressionStream { MaybeOwned<Stream> { *file } };
|
||||
|
|
|
@ -115,7 +115,7 @@ TEST_CASE(bool_option)
|
|||
TEST_CASE(positional_string_argument)
|
||||
{
|
||||
// Single required string argument
|
||||
DeprecatedString name = "";
|
||||
ByteString name = "";
|
||||
auto parser_result = run_parser({ "app"sv, "buggie"sv }, [&](auto& parser) {
|
||||
parser.add_positional_argument(name, "name", "name", Core::ArgsParser::Required::Yes);
|
||||
});
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
|
||||
constexpr StringView TESTS_ROOT_DIR = "/home/anon/Tests/cpp-tests/parser"sv;
|
||||
|
||||
static DeprecatedString read_all(DeprecatedString const& path)
|
||||
static ByteString read_all(ByteString const& path)
|
||||
{
|
||||
auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
auto file_size = MUST(file->size());
|
||||
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
|
||||
MUST(file->read_until_filled(content.bytes()));
|
||||
return DeprecatedString { content.bytes() };
|
||||
return ByteString { content.bytes() };
|
||||
}
|
||||
|
||||
TEST_CASE(test_regression)
|
||||
|
@ -32,7 +32,7 @@ TEST_CASE(test_regression)
|
|||
outln("Checking {}...", path.basename());
|
||||
auto file_path = path.string();
|
||||
|
||||
auto ast_file_path = DeprecatedString::formatted("{}.ast", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1));
|
||||
auto ast_file_path = ByteString::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);
|
||||
|
@ -68,7 +68,7 @@ TEST_CASE(test_regression)
|
|||
|
||||
fclose(input_stream);
|
||||
|
||||
DeprecatedString content { reinterpret_cast<char const*>(buffer.data()), buffer.size() };
|
||||
ByteString content { reinterpret_cast<char const*>(buffer.data()), buffer.size() };
|
||||
|
||||
auto equal = content == target_ast;
|
||||
EXPECT(equal);
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
|
||||
constexpr StringView TESTS_ROOT_DIR = "/home/anon/Tests/cpp-tests/preprocessor"sv;
|
||||
|
||||
static DeprecatedString read_all(DeprecatedString const& path)
|
||||
static ByteString read_all(ByteString const& path)
|
||||
{
|
||||
auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read));
|
||||
auto file_size = MUST(file->size());
|
||||
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
|
||||
MUST(file->read_until_filled(content.bytes()));
|
||||
return DeprecatedString { content.bytes() };
|
||||
return ByteString { content.bytes() };
|
||||
}
|
||||
|
||||
TEST_CASE(test_regression)
|
||||
|
@ -31,7 +31,7 @@ TEST_CASE(test_regression)
|
|||
outln("Checking {}...", path.basename());
|
||||
auto file_path = path.string();
|
||||
|
||||
auto ast_file_path = DeprecatedString::formatted("{}.txt", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1));
|
||||
auto ast_file_path = ByteString::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);
|
||||
|
@ -44,7 +44,7 @@ TEST_CASE(test_regression)
|
|||
|
||||
EXPECT_EQ(tokens.size(), target_lines.size());
|
||||
for (size_t i = 0; i < tokens.size(); ++i) {
|
||||
EXPECT_EQ(tokens[i].to_deprecated_string(), target_lines[i]);
|
||||
EXPECT_EQ(tokens[i].to_byte_string(), target_lines[i]);
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
}));
|
||||
|
|
|
@ -15,11 +15,11 @@ TEST_CASE(test_adler32)
|
|||
EXPECT_EQ(digest, expected_result);
|
||||
};
|
||||
|
||||
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);
|
||||
do_test(ByteString("").bytes(), 0x1);
|
||||
do_test(ByteString("a").bytes(), 0x00620062);
|
||||
do_test(ByteString("abc").bytes(), 0x024d0127);
|
||||
do_test(ByteString("message digest").bytes(), 0x29750586);
|
||||
do_test(ByteString("abcdefghijklmnopqrstuvwxyz").bytes(), 0x90860b20);
|
||||
}
|
||||
|
||||
TEST_CASE(test_crc32)
|
||||
|
@ -29,7 +29,7 @@ TEST_CASE(test_crc32)
|
|||
EXPECT_EQ(digest, expected_result);
|
||||
};
|
||||
|
||||
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);
|
||||
do_test(ByteString("").bytes(), 0x0);
|
||||
do_test(ByteString("The quick brown fox jumps over the lazy dog").bytes(), 0x414FA339);
|
||||
do_test(ByteString("various CRC algorithms input data").bytes(), 0x9BD366AE);
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ TEST_CASE(test_interp_header_tiny_p_filesz)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_deprecated_string();
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -113,8 +113,8 @@ TEST_CASE(test_interp_header_p_filesz_larger_than_p_memsz)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_deprecated_string();
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -172,8 +172,8 @@ 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_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_deprecated_string();
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -228,8 +228,8 @@ TEST_CASE(test_load_header_p_memsz_zero)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_deprecated_string();
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -284,8 +284,8 @@ TEST_CASE(test_load_header_p_memsz_not_equal_to_p_align)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_deprecated_string();
|
||||
auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd)));
|
||||
auto elf_path = elf_path_string.to_byte_string();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGL/GL/gl.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 = DeprecatedString::formatted("{}.qoi", test_name);
|
||||
auto reference_filename = ByteString::formatted("{}.qoi", test_name);
|
||||
|
||||
if constexpr (SAVE_OUTPUT) {
|
||||
auto target_path = LexicalPath("/home/anon").append(reference_filename);
|
||||
|
@ -40,7 +40,7 @@ static void expect_bitmap_equals_reference(Gfx::Bitmap const& bitmap, StringView
|
|||
MUST(qoi_output_stream->write_until_depleted(qoi_buffer));
|
||||
}
|
||||
|
||||
auto reference_image_path = DeprecatedString::formatted(REFERENCE_IMAGE_DIR "/{}", reference_filename);
|
||||
auto reference_image_path = ByteString::formatted(REFERENCE_IMAGE_DIR "/{}", reference_filename);
|
||||
auto reference_bitmap = MUST(Gfx::Bitmap::load_from_file(reference_image_path));
|
||||
EXPECT_EQ(reference_bitmap->visually_equals(bitmap), true);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST_CASE(test_regression)
|
|||
return IterationDecision::Continue;
|
||||
|
||||
outln("Checking {}...", path.basename());
|
||||
String file_path = MUST(String::from_deprecated_string(path.string()));
|
||||
String file_path = MUST(String::from_byte_string(path.string()));
|
||||
|
||||
auto ast_file_path = MUST(String::formatted("{}.ast", MUST(file_path.substring_from_byte_offset(0, file_path.bytes_as_string_view().length() - sizeof(".glsl") + 1))));
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibGfx/ImageFormats/BMPLoader.h>
|
||||
#include <LibGfx/ImageFormats/DDSLoader.h>
|
||||
|
|
|
@ -44,7 +44,7 @@ TEST_CASE(test_decode)
|
|||
illegal_character_builder.append(byte);
|
||||
}
|
||||
|
||||
auto illegal_character_decode = MUST(IMAP::decode_quoted_printable(illegal_character_builder.to_deprecated_string()));
|
||||
auto illegal_character_decode = MUST(IMAP::decode_quoted_printable(illegal_character_builder.to_byte_string()));
|
||||
EXPECT(illegal_character_decode.is_empty());
|
||||
|
||||
// If an escape sequence is invalid the characters are output unaltered. Illegal characters are ignored as usual.
|
||||
|
|
|
@ -22,7 +22,7 @@ TESTJS_GLOBAL_FUNCTION(is_strict_mode, isStrictMode, 0)
|
|||
|
||||
TESTJS_GLOBAL_FUNCTION(can_parse_source, canParseSource)
|
||||
{
|
||||
auto source = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto source = TRY(vm.argument(0).to_byte_string(vm));
|
||||
auto parser = JS::Parser(JS::Lexer(source));
|
||||
(void)parser.parse_program();
|
||||
return JS::Value(!parser.has_errors());
|
||||
|
@ -65,14 +65,14 @@ TESTJS_GLOBAL_FUNCTION(mark_as_garbage, markAsGarbage)
|
|||
return execution_context->lexical_environment != nullptr;
|
||||
});
|
||||
if (!outer_environment.has_value())
|
||||
return vm.throw_completion<JS::ReferenceError>(JS::ErrorType::UnknownIdentifier, variable_name.deprecated_string());
|
||||
return vm.throw_completion<JS::ReferenceError>(JS::ErrorType::UnknownIdentifier, variable_name.byte_string());
|
||||
|
||||
auto reference = TRY(vm.resolve_binding(variable_name.deprecated_string(), outer_environment.value()->lexical_environment));
|
||||
auto reference = TRY(vm.resolve_binding(variable_name.byte_string(), outer_environment.value()->lexical_environment));
|
||||
|
||||
auto value = TRY(reference.get_value(vm));
|
||||
|
||||
if (!can_be_held_weakly(value))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::CannotBeHeldWeakly, DeprecatedString::formatted("Variable with name {}", variable_name.deprecated_string()));
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::CannotBeHeldWeakly, ByteString::formatted("Variable with name {}", variable_name.byte_string()));
|
||||
|
||||
vm.heap().uproot_cell(&value.as_cell());
|
||||
TRY(reference.delete_(vm));
|
||||
|
@ -111,7 +111,7 @@ TESTJS_GLOBAL_FUNCTION(set_time_zone, setTimeZone)
|
|||
return current_time_zone;
|
||||
}
|
||||
|
||||
TESTJS_RUN_FILE_FUNCTION(DeprecatedString const& test_file, JS::Realm& realm, JS::ExecutionContext&)
|
||||
TESTJS_RUN_FILE_FUNCTION(ByteString const& test_file, JS::Realm& realm, JS::ExecutionContext&)
|
||||
{
|
||||
if (!test262_parser_tests)
|
||||
return Test::JS::RunFileHookResult::RunAsNormal;
|
||||
|
@ -146,8 +146,8 @@ TESTJS_RUN_FILE_FUNCTION(DeprecatedString const& test_file, JS::Realm& realm, JS
|
|||
parse_succeeded = !Test::JS::parse_script(test_file, realm).is_error();
|
||||
|
||||
bool test_passed = true;
|
||||
DeprecatedString message;
|
||||
DeprecatedString expectation_string;
|
||||
ByteString message;
|
||||
ByteString expectation_string;
|
||||
|
||||
switch (expectation) {
|
||||
case Early:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/JsonObject.h>
|
||||
|
@ -107,7 +107,7 @@ static StringView emoji_for_result(TestResult result)
|
|||
|
||||
static constexpr StringView total_test_emoji = "🧪"sv;
|
||||
|
||||
static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString> files, size_t offset, StringView command, char const* const arguments[])
|
||||
static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<ByteString> files, size_t offset, StringView command, char const* const arguments[])
|
||||
{
|
||||
HashMap<size_t, TestResult> results {};
|
||||
TRY(results.try_ensure_capacity(files.size()));
|
||||
|
@ -133,12 +133,12 @@ static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString
|
|||
}
|
||||
|
||||
auto output_or_error = runner_process->read_all();
|
||||
DeprecatedString output;
|
||||
ByteString output;
|
||||
|
||||
if (output_or_error.is_error())
|
||||
warnln("Got error: {} while reading runner output", output_or_error.error());
|
||||
else
|
||||
output = DeprecatedString(output_or_error.release_value().standard_error.bytes(), Chomp);
|
||||
output = ByteString(output_or_error.release_value().standard_error.bytes(), Chomp);
|
||||
|
||||
auto status_or_error = runner_process->status();
|
||||
bool failed = false;
|
||||
|
@ -162,7 +162,7 @@ static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString
|
|||
auto result_object_or_error = parser.parse();
|
||||
if (!result_object_or_error.is_error() && result_object_or_error.value().is_object()) {
|
||||
auto& result_object = result_object_or_error.value().as_object();
|
||||
if (auto result_string = result_object.get_deprecated_string("result"sv); result_string.has_value()) {
|
||||
if (auto result_string = result_object.get_byte_string("result"sv); result_string.has_value()) {
|
||||
auto const& view = result_string.value();
|
||||
// Timeout and assert fail already are the result of the stopping test
|
||||
if (view == "timeout"sv || view == "assert_fail"sv) {
|
||||
|
@ -190,7 +190,7 @@ static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString
|
|||
return results;
|
||||
}
|
||||
|
||||
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<DeprecatedString> const& paths, StringView per_file_name, double time_taken_in_ms);
|
||||
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<ByteString> const& paths, StringView per_file_name, double time_taken_in_ms);
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
|
@ -213,12 +213,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.parse(arguments);
|
||||
|
||||
// Normalize the path to ensure filenames are consistent
|
||||
Vector<DeprecatedString> paths;
|
||||
Vector<ByteString> paths;
|
||||
|
||||
if (!FileSystem::is_directory(test_directory)) {
|
||||
paths.append(test_directory);
|
||||
} else {
|
||||
Test::iterate_directory_recursively(LexicalPath::canonicalized_path(test_directory), [&](DeprecatedString const& file_path) {
|
||||
Test::iterate_directory_recursively(LexicalPath::canonicalized_path(test_directory), [&](ByteString const& file_path) {
|
||||
if (file_path.contains("_FIXTURE"sv))
|
||||
return;
|
||||
// FIXME: Add ignored file set
|
||||
|
@ -230,7 +230,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
outln("Found {} tests", paths.size());
|
||||
|
||||
auto parameters = pass_through_parameters.split_view(' ');
|
||||
Vector<DeprecatedString> args;
|
||||
Vector<ByteString> args;
|
||||
args.ensure_capacity(parameters.size() + 2);
|
||||
args.append(runner_command);
|
||||
if (!dont_disable_core_dump)
|
||||
|
@ -301,7 +301,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<DeprecatedString> const& paths, StringView per_file_name, double time_taken_in_ms)
|
||||
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<ByteString> const& paths, StringView per_file_name, double time_taken_in_ms)
|
||||
{
|
||||
|
||||
auto file_or_error = Core::File::open(per_file_name, Core::File::OpenMode::Write);
|
||||
|
@ -320,7 +320,7 @@ void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<Deprec
|
|||
complete_results.set("duration", time_taken_in_ms / 1000.);
|
||||
complete_results.set("results", result_object);
|
||||
|
||||
if (file->write_until_depleted(complete_results.to_deprecated_string().bytes()).is_error())
|
||||
if (file->write_until_depleted(complete_results.to_byte_string().bytes()).is_error())
|
||||
warnln("Failed to write per-file");
|
||||
file->close();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/Result.h>
|
||||
|
@ -32,9 +32,9 @@
|
|||
# include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
static DeprecatedString s_current_test = "";
|
||||
static ByteString s_current_test = "";
|
||||
static bool s_parse_only = false;
|
||||
static DeprecatedString s_harness_file_directory;
|
||||
static ByteString s_harness_file_directory;
|
||||
static bool s_automatic_harness_detection_mode = false;
|
||||
|
||||
enum class NegativePhase {
|
||||
|
@ -46,9 +46,9 @@ enum class NegativePhase {
|
|||
|
||||
struct TestError {
|
||||
NegativePhase phase { NegativePhase::ParseOrEarly };
|
||||
DeprecatedString type;
|
||||
DeprecatedString details;
|
||||
DeprecatedString harness_file;
|
||||
ByteString type;
|
||||
ByteString details;
|
||||
ByteString harness_file;
|
||||
};
|
||||
|
||||
using ScriptOrModuleProgram = Variant<JS::NonnullGCPtr<JS::Script>, JS::NonnullGCPtr<JS::SourceTextModule>>;
|
||||
|
@ -61,7 +61,7 @@ static Result<ScriptOrModuleProgram, TestError> parse_program(JS::Realm& realm,
|
|||
return TestError {
|
||||
NegativePhase::ParseOrEarly,
|
||||
"SyntaxError",
|
||||
script_or_error.error()[0].to_deprecated_string(),
|
||||
script_or_error.error()[0].to_byte_string(),
|
||||
""
|
||||
};
|
||||
}
|
||||
|
@ -92,39 +92,39 @@ static Result<void, TestError> run_program(InterpreterT& interpreter, ScriptOrMo
|
|||
|
||||
auto name = object.get_without_side_effects("name");
|
||||
if (!name.is_empty() && !name.is_accessor()) {
|
||||
error.type = name.to_string_without_side_effects().to_deprecated_string();
|
||||
error.type = name.to_string_without_side_effects().to_byte_string();
|
||||
} else {
|
||||
auto constructor = object.get_without_side_effects("constructor");
|
||||
if (constructor.is_object()) {
|
||||
name = constructor.as_object().get_without_side_effects("name");
|
||||
if (!name.is_undefined())
|
||||
error.type = name.to_string_without_side_effects().to_deprecated_string();
|
||||
error.type = name.to_string_without_side_effects().to_byte_string();
|
||||
}
|
||||
}
|
||||
|
||||
auto message = object.get_without_side_effects("message");
|
||||
if (!message.is_empty() && !message.is_accessor())
|
||||
error.details = message.to_string_without_side_effects().to_deprecated_string();
|
||||
error.details = message.to_string_without_side_effects().to_byte_string();
|
||||
}
|
||||
if (error.type.is_empty())
|
||||
error.type = error_value.to_string_without_side_effects().to_deprecated_string();
|
||||
error.type = error_value.to_string_without_side_effects().to_byte_string();
|
||||
return error;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
static HashMap<DeprecatedString, DeprecatedString> s_cached_harness_files;
|
||||
static HashMap<ByteString, ByteString> 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::File::open(DeprecatedString::formatted("{}{}", s_harness_file_directory, harness_file), Core::File::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open(ByteString::formatted("{}{}", s_harness_file_directory, harness_file), Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
return TestError {
|
||||
NegativePhase::Harness,
|
||||
"filesystem",
|
||||
DeprecatedString::formatted("Could not open file: {}", harness_file),
|
||||
ByteString::formatted("Could not open file: {}", harness_file),
|
||||
harness_file
|
||||
};
|
||||
}
|
||||
|
@ -134,13 +134,13 @@ static Result<StringView, TestError> read_harness_file(StringView harness_file)
|
|||
return TestError {
|
||||
NegativePhase::Harness,
|
||||
"filesystem",
|
||||
DeprecatedString::formatted("Could not read file: {}", harness_file),
|
||||
ByteString::formatted("Could not read file: {}", harness_file),
|
||||
harness_file
|
||||
};
|
||||
}
|
||||
|
||||
StringView contents_view = contents_or_error.value();
|
||||
s_cached_harness_files.set(harness_file, contents_view.to_deprecated_string());
|
||||
s_cached_harness_files.set(harness_file, contents_view.to_byte_string());
|
||||
cache = s_cached_harness_files.find(harness_file);
|
||||
VERIFY(cache != s_cached_harness_files.end());
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ static Result<void, TestError> run_test(StringView source, StringView filepath,
|
|||
return TestError {
|
||||
NegativePhase::ParseOrEarly,
|
||||
"SyntaxError",
|
||||
parser.errors()[0].to_deprecated_string(),
|
||||
parser.errors()[0].to_byte_string(),
|
||||
""
|
||||
};
|
||||
}
|
||||
|
@ -250,14 +250,14 @@ static Result<void, TestError> run_test(StringView source, StringView filepath,
|
|||
return run_program(vm->bytecode_interpreter(), program_or_error.value());
|
||||
}
|
||||
|
||||
static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source)
|
||||
static Result<TestMetadata, ByteString> extract_metadata(StringView source)
|
||||
{
|
||||
auto lines = source.lines();
|
||||
|
||||
TestMetadata metadata;
|
||||
|
||||
bool parsing_negative = false;
|
||||
DeprecatedString failed_message;
|
||||
ByteString failed_message;
|
||||
|
||||
auto parse_list = [&](StringView line) {
|
||||
auto start = line.find('[');
|
||||
|
@ -268,7 +268,7 @@ static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source
|
|||
|
||||
auto end = line.find_last(']');
|
||||
if (!end.has_value() || end.value() <= start.value()) {
|
||||
failed_message = DeprecatedString::formatted("Can't parse list in '{}'", line);
|
||||
failed_message = ByteString::formatted("Can't parse list in '{}'", line);
|
||||
return items;
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source
|
|||
auto second_word = [&](StringView line) {
|
||||
auto separator = line.find(' ');
|
||||
if (!separator.has_value() || separator.value() >= (line.length() - 1u)) {
|
||||
failed_message = DeprecatedString::formatted("Can't parse value after space in '{}'", line);
|
||||
failed_message = ByteString::formatted("Can't parse value after space in '{}'", line);
|
||||
return ""sv;
|
||||
}
|
||||
return line.substring_view(separator.value() + 1);
|
||||
|
@ -335,7 +335,7 @@ static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source
|
|||
metadata.phase = NegativePhase::Runtime;
|
||||
} else {
|
||||
has_phase = false;
|
||||
failed_message = DeprecatedString::formatted("Unknown negative phase: {}", phase);
|
||||
failed_message = ByteString::formatted("Unknown negative phase: {}", phase);
|
||||
break;
|
||||
}
|
||||
} else if (line.starts_with("type:"sv)) {
|
||||
|
@ -392,7 +392,7 @@ static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source
|
|||
}
|
||||
|
||||
if (failed_message.is_empty())
|
||||
failed_message = DeprecatedString::formatted("Never reached end of comment '---*/'");
|
||||
failed_message = ByteString::formatted("Never reached end of comment '---*/'");
|
||||
|
||||
return failed_message;
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ static bool verify_test(Result<void, TestError>& result, TestMetadata const& met
|
|||
}
|
||||
|
||||
if (metadata.is_async && output.has("output"sv)) {
|
||||
auto output_messages = output.get_deprecated_string("output"sv);
|
||||
auto output_messages = output.get_byte_string("output"sv);
|
||||
VERIFY(output_messages.has_value());
|
||||
if (output_messages->contains("AsyncTestFailure:InternalError: TODO("sv)) {
|
||||
output.set("todo_error", true);
|
||||
|
@ -467,7 +467,7 @@ static bool verify_test(Result<void, TestError>& result, TestMetadata const& met
|
|||
|
||||
JsonObject expected_error_object;
|
||||
expected_error_object.set("phase", phase_to_string(metadata.phase));
|
||||
expected_error_object.set("type", metadata.type.to_deprecated_string());
|
||||
expected_error_object.set("type", metadata.type.to_byte_string());
|
||||
|
||||
expected_error = expected_error_object;
|
||||
|
||||
|
@ -506,7 +506,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(DeprecatedString const& test_file_path)
|
||||
static bool extract_harness_directory(ByteString const& test_file_path)
|
||||
{
|
||||
auto test_directory_index = test_file_path.find("test/"sv);
|
||||
if (!test_directory_index.has_value()) {
|
||||
|
@ -514,7 +514,7 @@ static bool extract_harness_directory(DeprecatedString const& test_file_path)
|
|||
return false;
|
||||
}
|
||||
|
||||
s_harness_file_directory = DeprecatedString::formatted("{}harness/", test_file_path.substring_view(0, test_directory_index.value()));
|
||||
s_harness_file_directory = ByteString::formatted("{}harness/", test_file_path.substring_view(0, test_directory_index.value()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -532,7 +532,7 @@ static bool g_in_assert = false;
|
|||
assert_fail_result.set("assert_fail", true);
|
||||
assert_fail_result.set("result", "assert_fail");
|
||||
assert_fail_result.set("output", assert_failed_message);
|
||||
outln(saved_stdout_fd, "RESULT {}{}", assert_fail_result.to_deprecated_string(), '\0');
|
||||
outln(saved_stdout_fd, "RESULT {}{}", assert_fail_result.to_byte_string(), '\0');
|
||||
// (Attempt to) Ensure that messages are written before quitting.
|
||||
fflush(saved_stdout_fd);
|
||||
fflush(stderr);
|
||||
|
@ -555,7 +555,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 = DeprecatedString::formatted("{}:{}: {}: Assertion `{}' failed.", file, line, function, assertion);
|
||||
auto full_message = ByteString::formatted("{}:{}: {}: Assertion `{}' failed.", file, line, function, assertion);
|
||||
handle_failed_assert(full_message.characters());
|
||||
}
|
||||
#endif
|
||||
|
@ -598,7 +598,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 = DeprecatedString::formatted("{}/", s_harness_file_directory);
|
||||
s_harness_file_directory = ByteString::formatted("{}/", s_harness_file_directory);
|
||||
}
|
||||
|
||||
if (timeout <= 0) {
|
||||
|
@ -651,10 +651,10 @@ int main(int argc, char** argv)
|
|||
auto collect_output = [&] {
|
||||
fflush(stdout);
|
||||
auto nread = read(stdout_pipe[0], buffer, BUFFER_SIZE);
|
||||
Optional<DeprecatedString> value;
|
||||
Optional<ByteString> value;
|
||||
|
||||
if (nread > 0) {
|
||||
value = DeprecatedString { buffer, static_cast<size_t>(nread) };
|
||||
value = ByteString { buffer, static_cast<size_t>(nread) };
|
||||
while (nread > 0) {
|
||||
nread = read(stdout_pipe[0], buffer, BUFFER_SIZE);
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ int main(int argc, char** argv)
|
|||
|
||||
count++;
|
||||
|
||||
DeprecatedString source_with_strict;
|
||||
ByteString source_with_strict;
|
||||
static StringView use_strict = "'use strict';\n"sv;
|
||||
static size_t strict_length = use_strict.length();
|
||||
|
||||
|
@ -721,7 +721,7 @@ int main(int argc, char** argv)
|
|||
StringBuilder builder { contents.size() + strict_length };
|
||||
builder.append(use_strict);
|
||||
builder.append(contents);
|
||||
source_with_strict = builder.to_deprecated_string();
|
||||
source_with_strict = builder.to_byte_string();
|
||||
}
|
||||
|
||||
StringView with_strict = source_with_strict.view();
|
||||
|
@ -731,7 +731,7 @@ int main(int argc, char** argv)
|
|||
result_object.set("test", path);
|
||||
|
||||
ScopeGuard output_guard = [&] {
|
||||
outln(saved_stdout_fd, "RESULT {}{}", result_object.to_deprecated_string(), '\0');
|
||||
outln(saved_stdout_fd, "RESULT {}{}", result_object.to_byte_string(), '\0');
|
||||
fflush(saved_stdout_fd);
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonParser.h>
|
||||
|
@ -23,20 +23,20 @@ TEST_SETUP
|
|||
auto file_size = MUST(file->size());
|
||||
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
|
||||
MUST(file->read_until_filled(content.bytes()));
|
||||
DeprecatedString test_data { content.bytes() };
|
||||
ByteString 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 = DeprecatedString::formatted("{}_ex{}_{}..{}",
|
||||
auto name = ByteString::formatted("{}_ex{}_{}..{}",
|
||||
testcase.get("section"sv).value(),
|
||||
testcase.get("example"sv).value(),
|
||||
testcase.get("start_line"sv).value(),
|
||||
testcase.get("end_line"sv).value());
|
||||
|
||||
DeprecatedString markdown = testcase.get_deprecated_string("markdown"sv).value();
|
||||
DeprecatedString html = testcase.get_deprecated_string("html"sv).value();
|
||||
ByteString markdown = testcase.get_byte_string("markdown"sv).value();
|
||||
ByteString html = testcase.get_byte_string("html"sv).value();
|
||||
|
||||
Test::TestSuite::the().add_case(adopt_ref(*new Test::TestCase(
|
||||
name, [markdown, html]() {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibPDF/CommonNames.h>
|
||||
|
@ -65,7 +65,7 @@ TEST_CASE(encodig)
|
|||
|
||||
TEST_CASE(truncated_pdf_header_issue_10717)
|
||||
{
|
||||
AK::DeprecatedString string { "%PDF-2.11%" };
|
||||
AK::ByteString string { "%PDF-2.11%" };
|
||||
auto document = PDF::Document::create(string.bytes());
|
||||
EXPECT(document.is_error());
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ TEST_CASE(regex_lexer)
|
|||
|
||||
TEST_CASE(parser_error_parens)
|
||||
{
|
||||
DeprecatedString pattern = "test()test";
|
||||
ByteString pattern = "test()test";
|
||||
Lexer l(pattern);
|
||||
PosixExtendedParser p(l);
|
||||
p.parse();
|
||||
|
@ -132,7 +132,7 @@ TEST_CASE(parser_error_parens)
|
|||
|
||||
TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
||||
{
|
||||
DeprecatedString pattern;
|
||||
ByteString pattern;
|
||||
Vector<char, 5> chars = { '*', '+', '?', '{' };
|
||||
StringBuilder b;
|
||||
|
||||
|
@ -143,7 +143,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
// First in ere
|
||||
b.clear();
|
||||
b.append(ch);
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -153,7 +153,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append("a|"sv);
|
||||
b.append(ch);
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -163,7 +163,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append('^');
|
||||
b.append(ch);
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -173,7 +173,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append('$');
|
||||
b.append(ch);
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -184,7 +184,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.append('(');
|
||||
b.append(ch);
|
||||
b.append(')');
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
l.set_source(pattern);
|
||||
p.parse();
|
||||
EXPECT(p.has_error());
|
||||
|
@ -267,7 +267,7 @@ TEST_CASE(catch_all_newline)
|
|||
Regex<PosixExtended> re("^.*$", PosixFlags::Multiline | PosixFlags::StringCopyMatches);
|
||||
RegexResult result;
|
||||
auto lambda = [&result, &re]() {
|
||||
DeprecatedString aaa = "Hello World\nTest\n1234\n";
|
||||
ByteString aaa = "Hello World\nTest\n1234\n";
|
||||
result = match(aaa, re);
|
||||
EXPECT_EQ(result.success, true);
|
||||
};
|
||||
|
@ -283,11 +283,11 @@ TEST_CASE(catch_all_newline_view)
|
|||
Regex<PosixExtended> re("^.*$", PosixFlags::Multiline);
|
||||
RegexResult result;
|
||||
|
||||
DeprecatedString aaa = "Hello World\nTest\n1234\n";
|
||||
ByteString aaa = "Hello World\nTest\n1234\n";
|
||||
result = match(aaa, re);
|
||||
EXPECT_EQ(result.success, true);
|
||||
EXPECT_EQ(result.count, 3u);
|
||||
DeprecatedString str = "Hello World";
|
||||
ByteString 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");
|
||||
|
@ -313,7 +313,7 @@ TEST_CASE(catch_all_newline_2)
|
|||
TEST_CASE(match_all_character_class)
|
||||
{
|
||||
Regex<PosixExtended> re("[[:alpha:]]");
|
||||
DeprecatedString str = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
ByteString str = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
RegexResult result = match(str, re, PosixFlags::Global | PosixFlags::StringCopyMatches);
|
||||
|
||||
EXPECT_EQ(result.success, true);
|
||||
|
@ -326,7 +326,7 @@ TEST_CASE(match_all_character_class)
|
|||
TEST_CASE(match_character_class_with_assertion)
|
||||
{
|
||||
Regex<PosixExtended> re("[[:alpha:]]+$");
|
||||
DeprecatedString str = "abcdef";
|
||||
ByteString str = "abcdef";
|
||||
RegexResult result = match(str, re);
|
||||
|
||||
EXPECT_EQ(result.success, true);
|
||||
|
@ -372,13 +372,13 @@ TEST_CASE(ini_file_entries)
|
|||
regex_dbg.print_bytecode(re);
|
||||
}
|
||||
|
||||
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
ByteString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true);
|
||||
EXPECT_EQ(result.count, 3u);
|
||||
|
||||
if constexpr (REGEX_DEBUG) {
|
||||
for (auto& v : result.matches)
|
||||
fprintf(stderr, "%s\n", v.view.to_deprecated_string().characters());
|
||||
fprintf(stderr, "%s\n", v.view.to_byte_string().characters());
|
||||
}
|
||||
|
||||
EXPECT_EQ(result.matches.at(0).view, "[Window]");
|
||||
|
@ -400,7 +400,7 @@ TEST_CASE(ini_file_entries2)
|
|||
Regex<PosixExtended> re("[[:alpha:]]*=([[:digit:]]*)");
|
||||
RegexResult result;
|
||||
|
||||
DeprecatedString haystack = "ViewMode=Icon";
|
||||
ByteString haystack = "ViewMode=Icon";
|
||||
|
||||
EXPECT_EQ(re.match(haystack.view(), result), false);
|
||||
EXPECT_EQ(result.count, 0u);
|
||||
|
@ -421,7 +421,7 @@ TEST_CASE(named_capture_group)
|
|||
regex_dbg.print_bytecode(re);
|
||||
}
|
||||
|
||||
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
ByteString 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");
|
||||
|
@ -444,7 +444,7 @@ TEST_CASE(ecma262_named_capture_group_with_dollar_sign)
|
|||
regex_dbg.print_bytecode(re);
|
||||
}
|
||||
|
||||
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
ByteString 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");
|
||||
|
@ -467,7 +467,7 @@ TEST_CASE(a_star)
|
|||
regex_dbg.print_bytecode(re);
|
||||
}
|
||||
|
||||
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
ByteString 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) {
|
||||
|
@ -500,7 +500,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 = DeprecatedString::repeated("a|"sv, 100000);
|
||||
auto parse_test_case_long_disjunction_chain = ByteString::repeated("a|"sv, 100000);
|
||||
|
||||
TEST_CASE(ECMA262_parse)
|
||||
{
|
||||
|
@ -730,7 +730,7 @@ TEST_CASE(ECMA262_unicode_match)
|
|||
StringBuilder builder;
|
||||
for (u32 code_point : space_and_line_terminator_code_points)
|
||||
builder.append_code_point(code_point);
|
||||
auto space_and_line_terminators = builder.to_deprecated_string();
|
||||
auto space_and_line_terminators = builder.to_byte_string();
|
||||
|
||||
struct _test {
|
||||
StringView pattern;
|
||||
|
@ -969,7 +969,7 @@ TEST_CASE(case_insensitive_match)
|
|||
TEST_CASE(extremely_long_fork_chain)
|
||||
{
|
||||
Regex<ECMA262> re("(?:aa)*");
|
||||
auto result = re.match(DeprecatedString::repeated('a', 1000));
|
||||
auto result = re.match(ByteString::repeated('a', 1000));
|
||||
EXPECT_EQ(result.success, true);
|
||||
}
|
||||
|
||||
|
@ -988,7 +988,7 @@ TEST_CASE(theoretically_infinite_loop)
|
|||
}
|
||||
}
|
||||
|
||||
static auto g_lots_of_a_s = DeprecatedString::repeated('a', 10'000'000);
|
||||
static auto g_lots_of_a_s = ByteString::repeated('a', 10'000'000);
|
||||
|
||||
BENCHMARK_CASE(fork_performance)
|
||||
{
|
||||
|
@ -1137,7 +1137,7 @@ TEST_CASE(single_match_flag)
|
|||
auto result = re.match("ABC"sv);
|
||||
EXPECT_EQ(result.success, true);
|
||||
EXPECT_EQ(result.matches.size(), 1u);
|
||||
EXPECT_EQ(result.matches.first().view.to_deprecated_string(), "A"sv);
|
||||
EXPECT_EQ(result.matches.first().view.to_byte_string(), "A"sv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1149,7 +1149,7 @@ TEST_CASE(empty_string_wildcard_match)
|
|||
auto result = re.match(""sv);
|
||||
EXPECT_EQ(result.success, true);
|
||||
EXPECT_EQ(result.matches.size(), 1u);
|
||||
EXPECT_EQ(result.matches.first().view.to_deprecated_string(), ""sv);
|
||||
EXPECT_EQ(result.matches.first().view.to_byte_string(), ""sv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1162,7 +1162,7 @@ TEST_CASE(inversion_state_in_char_class)
|
|||
auto result = re.match("hello"sv);
|
||||
EXPECT_EQ(result.success, true);
|
||||
EXPECT_EQ(result.matches.size(), 1u);
|
||||
EXPECT_EQ(result.matches.first().view.to_deprecated_string(), "h"sv);
|
||||
EXPECT_EQ(result.matches.first().view.to_byte_string(), "h"sv);
|
||||
}
|
||||
{
|
||||
Regex<ECMA262> re("^(?:([^\\s!\"#%-,\\./;->@\\[-\\^`\\{-~]+(?=([=~}\\s/.)|]))))"sv, ECMAScriptFlags::Global);
|
||||
|
@ -1170,8 +1170,8 @@ TEST_CASE(inversion_state_in_char_class)
|
|||
auto result = re.match("slideNumbers}}"sv);
|
||||
EXPECT_EQ(result.success, true);
|
||||
EXPECT_EQ(result.matches.size(), 1u);
|
||||
EXPECT_EQ(result.matches.first().view.to_deprecated_string(), "slideNumbers"sv);
|
||||
EXPECT_EQ(result.capture_group_matches.first()[0].view.to_deprecated_string(), "slideNumbers"sv);
|
||||
EXPECT_EQ(result.capture_group_matches.first()[1].view.to_deprecated_string(), "}"sv);
|
||||
EXPECT_EQ(result.matches.first().view.to_byte_string(), "slideNumbers"sv);
|
||||
EXPECT_EQ(result.capture_group_matches.first()[0].view.to_byte_string(), "slideNumbers"sv);
|
||||
EXPECT_EQ(result.capture_group_matches.first()[1].view.to_byte_string(), "}"sv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
TEST_CASE(catch_all)
|
||||
{
|
||||
DeprecatedString pattern = "^.*$";
|
||||
ByteString pattern = "^.*$";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -24,7 +24,7 @@ TEST_CASE(catch_all)
|
|||
|
||||
TEST_CASE(simple_start)
|
||||
{
|
||||
DeprecatedString pattern = "^hello friends";
|
||||
ByteString pattern = "^hello friends";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -37,7 +37,7 @@ TEST_CASE(simple_start)
|
|||
|
||||
TEST_CASE(simple_end)
|
||||
{
|
||||
DeprecatedString pattern = ".*hello\\.\\.\\. there$";
|
||||
ByteString pattern = ".*hello\\.\\.\\. there$";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -51,7 +51,7 @@ TEST_CASE(simple_end)
|
|||
|
||||
TEST_CASE(simple_period)
|
||||
{
|
||||
DeprecatedString pattern = "hello.";
|
||||
ByteString pattern = "hello.";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -65,7 +65,7 @@ TEST_CASE(simple_period)
|
|||
|
||||
TEST_CASE(simple_period_end)
|
||||
{
|
||||
DeprecatedString pattern = "hello.$";
|
||||
ByteString pattern = "hello.$";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NOSUB), REG_NOERR);
|
||||
|
@ -79,7 +79,7 @@ TEST_CASE(simple_period_end)
|
|||
|
||||
TEST_CASE(simple_escaped)
|
||||
{
|
||||
DeprecatedString pattern = "hello\\.";
|
||||
ByteString pattern = "hello\\.";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -91,7 +91,7 @@ TEST_CASE(simple_escaped)
|
|||
|
||||
TEST_CASE(simple_period2_end)
|
||||
{
|
||||
DeprecatedString pattern = ".*hi... there$";
|
||||
ByteString pattern = ".*hi... there$";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -106,7 +106,7 @@ TEST_CASE(simple_period2_end)
|
|||
|
||||
TEST_CASE(simple_plus)
|
||||
{
|
||||
DeprecatedString pattern = "a+";
|
||||
ByteString pattern = "a+";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NOSUB), REG_NOERR);
|
||||
|
@ -120,7 +120,7 @@ TEST_CASE(simple_plus)
|
|||
|
||||
TEST_CASE(simple_questionmark)
|
||||
{
|
||||
DeprecatedString pattern = "da?d";
|
||||
ByteString pattern = "da?d";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -137,7 +137,7 @@ TEST_CASE(simple_questionmark)
|
|||
|
||||
TEST_CASE(simple_questionmark_matchall)
|
||||
{
|
||||
DeprecatedString pattern = "da?d";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "[[:alpha:]]";
|
||||
ByteString pattern = "[[:alpha:]]";
|
||||
regex_t regex;
|
||||
static constexpr int num_matches { 5 };
|
||||
regmatch_t matches[num_matches];
|
||||
|
||||
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
ByteString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
EXPECT_EQ(regexec(®ex, 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)
|
||||
{
|
||||
DeprecatedString pattern = "[[:alpha:]]*=([[:digit:]]*)|\\[(.*)\\]";
|
||||
ByteString pattern = "[[:alpha:]]*=([[:digit:]]*)|\\[(.*)\\]";
|
||||
regex_t regex;
|
||||
static constexpr int num_matches { 9 };
|
||||
regmatch_t matches[num_matches];
|
||||
|
||||
DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
ByteString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n";
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NEWLINE), REG_NOERR);
|
||||
EXPECT_EQ(regexec(®ex, haystack.characters(), num_matches, matches, 0), REG_NOERR);
|
||||
|
||||
|
@ -204,7 +204,7 @@ TEST_CASE(character_class2)
|
|||
fprintf(stderr, "Matches[%i].rm_so: %li, .rm_eo: %li .rm_cnt: %li: ", i, matches[i].rm_so, matches[i].rm_eo, matches[i].rm_cnt);
|
||||
fprintf(stderr, "haystack length: %lu\n", haystack.length());
|
||||
if (matches[i].rm_so != -1)
|
||||
fprintf(stderr, "%s\n", haystack.substring_view(matches[i].rm_so, matches[i].rm_eo - matches[i].rm_so).to_deprecated_string().characters());
|
||||
fprintf(stderr, "%s\n", haystack.substring_view(matches[i].rm_so, matches[i].rm_eo - matches[i].rm_so).to_byte_string().characters());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -235,7 +235,7 @@ TEST_CASE(character_class2)
|
|||
|
||||
TEST_CASE(escaped_char_questionmark)
|
||||
{
|
||||
DeprecatedString pattern = "This\\.?And\\.?That";
|
||||
ByteString pattern = "This\\.?And\\.?That";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -249,7 +249,7 @@ TEST_CASE(escaped_char_questionmark)
|
|||
|
||||
TEST_CASE(char_qualifier_asterisk)
|
||||
{
|
||||
DeprecatedString pattern = "regex*";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "😀";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "test(hello)test";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "test()test";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern;
|
||||
ByteString pattern;
|
||||
regex_t regex;
|
||||
static constexpr int num_matches { 5 };
|
||||
regmatch_t matches[num_matches];
|
||||
|
@ -325,7 +325,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
// First in ere
|
||||
b.clear();
|
||||
b.append(ch);
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
@ -334,7 +334,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append("a|"sv);
|
||||
b.append(ch);
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
@ -343,7 +343,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append('^');
|
||||
b.append(ch);
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
@ -352,7 +352,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.clear();
|
||||
b.append('$');
|
||||
b.append(ch);
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
@ -362,7 +362,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
b.append('(');
|
||||
b.append(ch);
|
||||
b.append(')');
|
||||
pattern = b.to_deprecated_string();
|
||||
pattern = b.to_byte_string();
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check);
|
||||
EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check);
|
||||
regfree(®ex);
|
||||
|
@ -371,7 +371,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place)
|
|||
|
||||
TEST_CASE(parser_error_vertical_line_used_at_wrong_place)
|
||||
{
|
||||
DeprecatedString pattern;
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "test(hello)?test";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "test(hello)*test";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "test(.*)test";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "test(a)?(b)?(c)?test";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "test(a)?(b)?(c)?test";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "test|hello|friends";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "test(a)?(b)?|hello ?(dear|my)? friends";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "(hello){3}";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "(hello){3,}";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "(hello){2,3}";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "c{3,30}";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "[abc]";
|
||||
ByteString pattern = "[abc]";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -980,7 +980,7 @@ TEST_CASE(simple_bracket_chars)
|
|||
|
||||
TEST_CASE(simple_bracket_chars_inverse)
|
||||
{
|
||||
DeprecatedString pattern = "[^abc]";
|
||||
ByteString pattern = "[^abc]";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -994,7 +994,7 @@ TEST_CASE(simple_bracket_chars_inverse)
|
|||
|
||||
TEST_CASE(simple_bracket_chars_range)
|
||||
{
|
||||
DeprecatedString pattern = "[a-d]";
|
||||
ByteString pattern = "[a-d]";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -1008,7 +1008,7 @@ TEST_CASE(simple_bracket_chars_range)
|
|||
|
||||
TEST_CASE(simple_bracket_chars_range_inverse)
|
||||
{
|
||||
DeprecatedString pattern = "[^a-df-z]";
|
||||
ByteString pattern = "[^a-df-z]";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -1024,7 +1024,7 @@ TEST_CASE(simple_bracket_chars_range_inverse)
|
|||
|
||||
TEST_CASE(bracket_character_class_uuid)
|
||||
{
|
||||
DeprecatedString pattern = "^([[:xdigit:]]{8})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{12})$";
|
||||
ByteString pattern = "^([[:xdigit:]]{8})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{12})$";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -1036,7 +1036,7 @@ TEST_CASE(bracket_character_class_uuid)
|
|||
|
||||
TEST_CASE(simple_bracket_character_class_inverse)
|
||||
{
|
||||
DeprecatedString pattern = "[^[:digit:]]";
|
||||
ByteString pattern = "[^[:digit:]]";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -1050,7 +1050,7 @@ TEST_CASE(simple_bracket_character_class_inverse)
|
|||
|
||||
TEST_CASE(email_address)
|
||||
{
|
||||
DeprecatedString pattern = "^[A-Z0-9a-z._%+-]{1,64}@(?:[A-Za-z0-9-]{1,63}\\.){1,125}[A-Za-z]{2,63}$";
|
||||
ByteString 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(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR);
|
||||
|
@ -1062,7 +1062,7 @@ TEST_CASE(email_address)
|
|||
|
||||
TEST_CASE(error_message)
|
||||
{
|
||||
DeprecatedString pattern = "^[A-Z0-9[a-z._%+-]{1,64}@[A-Za-z0-9-]{1,63}\\.{1,125}[A-Za-z]{2,63}$";
|
||||
ByteString 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(®ex, 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, ®ex, buf, buflen);
|
||||
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.";
|
||||
ByteString 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)
|
||||
{
|
||||
DeprecatedString pattern = "^hello friends";
|
||||
ByteString pattern = "^hello friends";
|
||||
regex_t regex;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NOSUB | REG_ICASE), REG_NOERR);
|
||||
|
@ -1098,8 +1098,8 @@ TEST_CASE(simple_ignorecase)
|
|||
|
||||
TEST_CASE(simple_notbol_noteol)
|
||||
{
|
||||
DeprecatedString pattern = "^hello friends$";
|
||||
DeprecatedString pattern2 = "hello friends";
|
||||
ByteString pattern = "^hello friends$";
|
||||
ByteString pattern2 = "hello friends";
|
||||
regex_t regex, regex2;
|
||||
|
||||
EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NOSUB | REG_ICASE), REG_NOERR);
|
||||
|
|
|
@ -46,7 +46,7 @@ static void insert_into_table(SQL::Database& db, int count)
|
|||
StringBuilder builder;
|
||||
builder.appendff("Test{}", ix);
|
||||
|
||||
row["TextColumn"] = builder.to_deprecated_string();
|
||||
row["TextColumn"] = builder.to_byte_string();
|
||||
row["IntColumn"] = ix;
|
||||
TRY_OR_FAIL(db.insert(row));
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ static void verify_table_contents(SQL::Database& db, int expected_count)
|
|||
for (auto& row : rows) {
|
||||
StringBuilder builder;
|
||||
builder.appendff("Test{}", row["IntColumn"].to_int<i32>().value());
|
||||
EXPECT_EQ(row["TextColumn"].to_deprecated_string(), builder.to_deprecated_string());
|
||||
EXPECT_EQ(row["TextColumn"].to_byte_string(), builder.to_byte_string());
|
||||
count++;
|
||||
sum += row["IntColumn"].to_int<i32>().value();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Expression>, DeprecatedString>;
|
||||
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Expression>, ByteString>;
|
||||
|
||||
ParseResult parse(StringView sql)
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ ParseResult parse(StringView sql)
|
|||
auto expression = parser.parse();
|
||||
|
||||
if (parser.has_errors()) {
|
||||
return parser.errors()[0].to_deprecated_string();
|
||||
return parser.errors()[0].to_byte_string();
|
||||
}
|
||||
|
||||
return expression;
|
||||
|
@ -225,14 +225,14 @@ TEST_CASE(binary_operator)
|
|||
StringBuilder builder;
|
||||
builder.append("1 "sv);
|
||||
builder.append(op.key);
|
||||
EXPECT(parse(builder.to_deprecated_string()).is_error());
|
||||
EXPECT(parse(builder.to_byte_string()).is_error());
|
||||
|
||||
builder.clear();
|
||||
|
||||
if (op.key != "+" && op.key != "-") { // "+1" and "-1" are fine (unary operator).
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
EXPECT(parse(builder.to_deprecated_string()).is_error());
|
||||
EXPECT(parse(builder.to_byte_string()).is_error());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ TEST_CASE(binary_operator)
|
|||
builder.append("1 "sv);
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
validate(builder.to_deprecated_string(), op.value);
|
||||
validate(builder.to_byte_string(), op.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -438,12 +438,12 @@ TEST_CASE(match_expression)
|
|||
StringBuilder builder;
|
||||
builder.append("1 "sv);
|
||||
builder.append(op.key);
|
||||
EXPECT(parse(builder.to_deprecated_string()).is_error());
|
||||
EXPECT(parse(builder.to_byte_string()).is_error());
|
||||
|
||||
builder.clear();
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
EXPECT(parse(builder.to_deprecated_string()).is_error());
|
||||
EXPECT(parse(builder.to_byte_string()).is_error());
|
||||
}
|
||||
|
||||
auto validate = [](StringView sql, SQL::AST::MatchOperator expected_operator, bool expected_invert_expression, bool expect_escape) {
|
||||
|
@ -463,19 +463,19 @@ TEST_CASE(match_expression)
|
|||
builder.append("1 "sv);
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
validate(builder.to_deprecated_string(), op.value, false, false);
|
||||
validate(builder.to_byte_string(), op.value, false, false);
|
||||
|
||||
builder.clear();
|
||||
builder.append("1 NOT "sv);
|
||||
builder.append(op.key);
|
||||
builder.append(" 1"sv);
|
||||
validate(builder.to_deprecated_string(), op.value, true, false);
|
||||
validate(builder.to_byte_string(), op.value, true, false);
|
||||
|
||||
builder.clear();
|
||||
builder.append("1 NOT "sv);
|
||||
builder.append(op.key);
|
||||
builder.append(" 1 ESCAPE '+'"sv);
|
||||
validate(builder.to_deprecated_string(), op.value, true, true);
|
||||
validate(builder.to_byte_string(), op.value, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -598,7 +598,7 @@ TEST_CASE(in_selection_expression)
|
|||
|
||||
TEST_CASE(expression_tree_depth_limit)
|
||||
{
|
||||
auto too_deep_expression = DeprecatedString::formatted("{:+^{}}1", "", SQL::AST::Limits::maximum_expression_tree_depth);
|
||||
auto too_deep_expression = ByteString::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());
|
||||
}
|
||||
|
|
|
@ -21,17 +21,17 @@ namespace {
|
|||
|
||||
constexpr char const* db_name = "/tmp/test.db";
|
||||
|
||||
SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database, DeprecatedString const& sql, Vector<SQL::Value> placeholder_values = {})
|
||||
SQL::ResultOr<SQL::ResultSet> try_execute(NonnullRefPtr<SQL::Database> database, ByteString const& sql, Vector<SQL::Value> placeholder_values = {})
|
||||
{
|
||||
auto parser = SQL::AST::Parser(SQL::AST::Lexer(sql));
|
||||
auto statement = parser.next_statement();
|
||||
EXPECT(!parser.has_errors());
|
||||
if (parser.has_errors())
|
||||
outln("{}", parser.errors()[0].to_deprecated_string());
|
||||
outln("{}", parser.errors()[0].to_byte_string());
|
||||
return statement->execute(move(database), placeholder_values);
|
||||
}
|
||||
|
||||
SQL::ResultSet execute(NonnullRefPtr<SQL::Database> database, DeprecatedString const& sql, Vector<SQL::Value> placeholder_values = {})
|
||||
SQL::ResultSet execute(NonnullRefPtr<SQL::Database> database, ByteString const& sql, Vector<SQL::Value> placeholder_values = {})
|
||||
{
|
||||
auto result = try_execute(move(database), sql, move(placeholder_values));
|
||||
if (result.is_error()) {
|
||||
|
@ -101,7 +101,7 @@ TEST_CASE(insert_into_table)
|
|||
int count = 0;
|
||||
auto rows = TRY_OR_FAIL(database->select_all(*table));
|
||||
for (auto& row : rows) {
|
||||
EXPECT_EQ(row["TEXTCOLUMN"].to_deprecated_string(), "Test");
|
||||
EXPECT_EQ(row["TEXTCOLUMN"].to_byte_string(), "Test");
|
||||
EXPECT_EQ(row["INTCOLUMN"].to_int<i32>(), 42);
|
||||
count++;
|
||||
}
|
||||
|
@ -380,8 +380,8 @@ TEST_CASE(select_inner_join)
|
|||
EXPECT_EQ(result.size(), 1u);
|
||||
EXPECT_EQ(result[0].row.size(), 3u);
|
||||
EXPECT_EQ(result[0].row[0].to_int<i32>(), 42);
|
||||
EXPECT_EQ(result[0].row[1].to_deprecated_string(), "Test_1");
|
||||
EXPECT_EQ(result[0].row[2].to_deprecated_string(), "Test_12");
|
||||
EXPECT_EQ(result[0].row[1].to_byte_string(), "Test_1");
|
||||
EXPECT_EQ(result[0].row[2].to_byte_string(), "Test_12");
|
||||
}
|
||||
|
||||
TEST_CASE(select_with_like)
|
||||
|
@ -467,11 +467,11 @@ TEST_CASE(select_with_order)
|
|||
|
||||
result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY TextColumn;");
|
||||
EXPECT_EQ(result.size(), 5u);
|
||||
EXPECT_EQ(result[0].row[0].to_deprecated_string(), "Test_1");
|
||||
EXPECT_EQ(result[1].row[0].to_deprecated_string(), "Test_2");
|
||||
EXPECT_EQ(result[2].row[0].to_deprecated_string(), "Test_3");
|
||||
EXPECT_EQ(result[3].row[0].to_deprecated_string(), "Test_4");
|
||||
EXPECT_EQ(result[4].row[0].to_deprecated_string(), "Test_5");
|
||||
EXPECT_EQ(result[0].row[0].to_byte_string(), "Test_1");
|
||||
EXPECT_EQ(result[1].row[0].to_byte_string(), "Test_2");
|
||||
EXPECT_EQ(result[2].row[0].to_byte_string(), "Test_3");
|
||||
EXPECT_EQ(result[3].row[0].to_byte_string(), "Test_4");
|
||||
EXPECT_EQ(result[4].row[0].to_byte_string(), "Test_5");
|
||||
}
|
||||
|
||||
TEST_CASE(select_with_regexp)
|
||||
|
@ -542,15 +542,15 @@ TEST_CASE(select_with_order_two_columns)
|
|||
|
||||
result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY TextColumn, IntColumn;");
|
||||
EXPECT_EQ(result.size(), 5u);
|
||||
EXPECT_EQ(result[0].row[0].to_deprecated_string(), "Test_1");
|
||||
EXPECT_EQ(result[0].row[0].to_byte_string(), "Test_1");
|
||||
EXPECT_EQ(result[0].row[1].to_int<i32>(), 47);
|
||||
EXPECT_EQ(result[1].row[0].to_deprecated_string(), "Test_2");
|
||||
EXPECT_EQ(result[1].row[0].to_byte_string(), "Test_2");
|
||||
EXPECT_EQ(result[1].row[1].to_int<i32>(), 40);
|
||||
EXPECT_EQ(result[2].row[0].to_deprecated_string(), "Test_2");
|
||||
EXPECT_EQ(result[2].row[0].to_byte_string(), "Test_2");
|
||||
EXPECT_EQ(result[2].row[1].to_int<i32>(), 42);
|
||||
EXPECT_EQ(result[3].row[0].to_deprecated_string(), "Test_4");
|
||||
EXPECT_EQ(result[3].row[0].to_byte_string(), "Test_4");
|
||||
EXPECT_EQ(result[3].row[1].to_int<i32>(), 41);
|
||||
EXPECT_EQ(result[4].row[0].to_deprecated_string(), "Test_5");
|
||||
EXPECT_EQ(result[4].row[0].to_byte_string(), "Test_5");
|
||||
EXPECT_EQ(result[4].row[1].to_int<i32>(), 44);
|
||||
}
|
||||
|
||||
|
@ -571,11 +571,11 @@ TEST_CASE(select_with_order_by_column_not_in_result)
|
|||
|
||||
result = execute(database, "SELECT TextColumn FROM TestSchema.TestTable ORDER BY IntColumn;");
|
||||
EXPECT_EQ(result.size(), 5u);
|
||||
EXPECT_EQ(result[0].row[0].to_deprecated_string(), "Test_3");
|
||||
EXPECT_EQ(result[1].row[0].to_deprecated_string(), "Test_4");
|
||||
EXPECT_EQ(result[2].row[0].to_deprecated_string(), "Test_2");
|
||||
EXPECT_EQ(result[3].row[0].to_deprecated_string(), "Test_5");
|
||||
EXPECT_EQ(result[4].row[0].to_deprecated_string(), "Test_1");
|
||||
EXPECT_EQ(result[0].row[0].to_byte_string(), "Test_3");
|
||||
EXPECT_EQ(result[1].row[0].to_byte_string(), "Test_4");
|
||||
EXPECT_EQ(result[2].row[0].to_byte_string(), "Test_2");
|
||||
EXPECT_EQ(result[3].row[0].to_byte_string(), "Test_5");
|
||||
EXPECT_EQ(result[4].row[0].to_byte_string(), "Test_1");
|
||||
}
|
||||
|
||||
TEST_CASE(select_with_limit)
|
||||
|
@ -586,7 +586,7 @@ TEST_CASE(select_with_limit)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
ByteString::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;");
|
||||
|
@ -602,7 +602,7 @@ TEST_CASE(select_with_limit_and_offset)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
ByteString::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;");
|
||||
|
@ -617,7 +617,7 @@ TEST_CASE(select_with_order_limit_and_offset)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
ByteString::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;");
|
||||
|
@ -642,7 +642,7 @@ TEST_CASE(select_with_limit_out_of_bounds)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
ByteString::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;");
|
||||
|
@ -657,7 +657,7 @@ TEST_CASE(select_with_offset_out_of_bounds)
|
|||
create_table(database);
|
||||
for (auto count = 0; count < 100; count++) {
|
||||
auto result = execute(database,
|
||||
DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count));
|
||||
ByteString::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;");
|
||||
|
@ -673,11 +673,11 @@ TEST_CASE(describe_table)
|
|||
auto result = execute(database, "DESCRIBE TABLE TestSchema.TestTable;");
|
||||
EXPECT_EQ(result.size(), 2u);
|
||||
|
||||
EXPECT_EQ(result[0].row[0].to_deprecated_string(), "TEXTCOLUMN");
|
||||
EXPECT_EQ(result[0].row[1].to_deprecated_string(), "text");
|
||||
EXPECT_EQ(result[0].row[0].to_byte_string(), "TEXTCOLUMN");
|
||||
EXPECT_EQ(result[0].row[1].to_byte_string(), "text");
|
||||
|
||||
EXPECT_EQ(result[1].row[0].to_deprecated_string(), "INTCOLUMN");
|
||||
EXPECT_EQ(result[1].row[1].to_deprecated_string(), "int");
|
||||
EXPECT_EQ(result[1].row[0].to_byte_string(), "INTCOLUMN");
|
||||
EXPECT_EQ(result[1].row[1].to_byte_string(), "int");
|
||||
}
|
||||
|
||||
TEST_CASE(binary_operator_execution)
|
||||
|
@ -688,7 +688,7 @@ TEST_CASE(binary_operator_execution)
|
|||
create_table(database);
|
||||
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -762,7 +762,7 @@ TEST_CASE(binary_operator_failure)
|
|||
create_table(database);
|
||||
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -772,7 +772,7 @@ TEST_CASE(binary_operator_failure)
|
|||
auto error = result.release_error();
|
||||
EXPECT_EQ(error.error(), SQL::SQLErrorCode::NumericOperatorTypeMismatch);
|
||||
|
||||
auto message = DeprecatedString::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op);
|
||||
auto message = ByteString::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op);
|
||||
EXPECT_EQ(error.error_string(), message);
|
||||
};
|
||||
|
||||
|
@ -832,7 +832,7 @@ TEST_CASE(delete_single_row)
|
|||
|
||||
create_table(database);
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -876,7 +876,7 @@ TEST_CASE(delete_multiple_rows)
|
|||
|
||||
create_table(database);
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -916,7 +916,7 @@ TEST_CASE(delete_all_rows)
|
|||
|
||||
create_table(database);
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -950,7 +950,7 @@ TEST_CASE(update_single_row)
|
|||
|
||||
create_table(database);
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -995,7 +995,7 @@ TEST_CASE(update_multiple_rows)
|
|||
|
||||
create_table(database);
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
@ -1036,7 +1036,7 @@ TEST_CASE(update_all_rows)
|
|||
|
||||
create_table(database);
|
||||
for (auto count = 0; count < 10; ++count) {
|
||||
auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count));
|
||||
EXPECT_EQ(result.size(), 1u);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/StringView.h>
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace {
|
||||
|
||||
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Statement>, DeprecatedString>;
|
||||
using ParseResult = AK::Result<NonnullRefPtr<SQL::AST::Statement>, ByteString>;
|
||||
|
||||
ParseResult parse(StringView sql)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ ParseResult parse(StringView sql)
|
|||
auto statement = parser.next_statement();
|
||||
|
||||
if (parser.has_errors()) {
|
||||
return parser.errors()[0].to_deprecated_string();
|
||||
return parser.errors()[0].to_byte_string();
|
||||
}
|
||||
|
||||
return statement;
|
||||
|
@ -393,7 +393,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<DeprecatedString>> 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<ByteString>> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector<StringView> expected_returned_column_aliases) {
|
||||
auto statement = TRY_OR_FAIL(parse(sql));
|
||||
EXPECT(is<SQL::AST::Update>(*statement));
|
||||
|
||||
|
@ -437,7 +437,7 @@ TEST_CASE(update)
|
|||
}
|
||||
};
|
||||
|
||||
Vector<Vector<DeprecatedString>> update_columns { { "COLUMN_NAME" } };
|
||||
Vector<Vector<ByteString>> 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, {});
|
||||
|
@ -578,7 +578,7 @@ TEST_CASE(select)
|
|||
};
|
||||
|
||||
struct Ordering {
|
||||
DeprecatedString collation_name;
|
||||
ByteString collation_name;
|
||||
SQL::Order order;
|
||||
SQL::Nulls nulls;
|
||||
};
|
||||
|
@ -752,16 +752,16 @@ TEST_CASE(common_table_expression)
|
|||
|
||||
TEST_CASE(nested_subquery_limit)
|
||||
{
|
||||
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());
|
||||
auto subquery = ByteString::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1);
|
||||
EXPECT(!parse(ByteString::formatted("SELECT * FROM {};"sv, subquery)).is_error());
|
||||
EXPECT(parse(ByteString::formatted("SELECT * FROM ({});"sv, subquery)).is_error());
|
||||
}
|
||||
|
||||
TEST_CASE(bound_parameter_limit)
|
||||
{
|
||||
auto subquery = DeprecatedString::repeated("?, "sv, SQL::AST::Limits::maximum_bound_parameters);
|
||||
EXPECT(!parse(DeprecatedString::formatted("INSERT INTO table_name VALUES ({}42);"sv, subquery)).is_error());
|
||||
EXPECT(parse(DeprecatedString::formatted("INSERT INTO table_name VALUES ({}?);"sv, subquery)).is_error());
|
||||
auto subquery = ByteString::repeated("?, "sv, SQL::AST::Limits::maximum_bound_parameters);
|
||||
EXPECT(!parse(ByteString::formatted("INSERT INTO table_name VALUES ({}42);"sv, subquery)).is_error());
|
||||
EXPECT(parse(ByteString::formatted("INSERT INTO table_name VALUES ({}?);"sv, subquery)).is_error());
|
||||
}
|
||||
|
||||
TEST_CASE(describe_table)
|
||||
|
|
|
@ -17,7 +17,7 @@ TEST_CASE(null_value)
|
|||
{
|
||||
SQL::Value v(SQL::SQLType::Null);
|
||||
EXPECT_EQ(v.type(), SQL::SQLType::Null);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "(null)"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "(null)"sv);
|
||||
EXPECT(!v.to_bool().has_value());
|
||||
EXPECT(!v.to_int<i32>().has_value());
|
||||
EXPECT(!v.to_int<u32>().has_value());
|
||||
|
@ -44,25 +44,25 @@ TEST_CASE(text_value)
|
|||
|
||||
v = "Test"sv;
|
||||
EXPECT_EQ(v.type(), SQL::SQLType::Text);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "Test"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "Test"sv);
|
||||
}
|
||||
{
|
||||
SQL::Value v(DeprecatedString("String Test"sv));
|
||||
SQL::Value v(ByteString("String Test"sv));
|
||||
EXPECT_EQ(v.type(), SQL::SQLType::Text);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "String Test"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "String Test"sv);
|
||||
|
||||
v = DeprecatedString("String Test 2"sv);
|
||||
v = ByteString("String Test 2"sv);
|
||||
EXPECT_EQ(v.type(), SQL::SQLType::Text);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "String Test 2"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "String Test 2"sv);
|
||||
}
|
||||
{
|
||||
SQL::Value v("const char * Test");
|
||||
EXPECT_EQ(v.type(), SQL::SQLType::Text);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "const char * Test"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "const char * Test"sv);
|
||||
|
||||
v = "const char * Test 2";
|
||||
EXPECT_EQ(v.type(), SQL::SQLType::Text);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "const char * Test 2"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "const char * Test 2"sv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ TEST_CASE(integer_value)
|
|||
|
||||
EXPECT(v.to_int<i32>().has_value());
|
||||
EXPECT_EQ(v.to_int<i32>().value(), 42);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "42"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "42"sv);
|
||||
|
||||
EXPECT(v.to_double().has_value());
|
||||
EXPECT((v.to_double().value() - 42.0) < NumericLimits<double>().epsilon());
|
||||
|
@ -261,7 +261,7 @@ TEST_CASE(float_value)
|
|||
|
||||
EXPECT(v.to_int<i32>().has_value());
|
||||
EXPECT_EQ(v.to_int<i32>().value(), 3);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "3.14");
|
||||
EXPECT_EQ(v.to_byte_string(), "3.14");
|
||||
|
||||
EXPECT(v.to_bool().has_value());
|
||||
EXPECT(v.to_bool().value());
|
||||
|
@ -274,7 +274,7 @@ TEST_CASE(float_value)
|
|||
|
||||
EXPECT(v.to_int<i32>().has_value());
|
||||
EXPECT_EQ(v.to_int<i32>().value(), 0);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "0"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "0"sv);
|
||||
|
||||
EXPECT(v.to_bool().has_value());
|
||||
EXPECT(!v.to_bool().value());
|
||||
|
@ -420,7 +420,7 @@ TEST_CASE(bool_value)
|
|||
|
||||
EXPECT(v.to_int<i32>().has_value());
|
||||
EXPECT_EQ(v.to_int<i32>().value(), 1);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "true"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "true"sv);
|
||||
|
||||
EXPECT(v.to_double().has_value());
|
||||
EXPECT((v.to_double().value() - 1.0) < NumericLimits<double>().epsilon());
|
||||
|
@ -434,7 +434,7 @@ TEST_CASE(bool_value)
|
|||
|
||||
EXPECT(v.to_int<i32>().has_value());
|
||||
EXPECT_EQ(v.to_int<i32>().value(), 0);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "false"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "false"sv);
|
||||
|
||||
EXPECT(v.to_double().has_value());
|
||||
EXPECT(v.to_double().value() < NumericLimits<double>().epsilon());
|
||||
|
@ -448,7 +448,7 @@ TEST_CASE(bool_value)
|
|||
|
||||
EXPECT(v.to_int<i32>().has_value());
|
||||
EXPECT_EQ(v.to_int<i32>().value(), 1);
|
||||
EXPECT_EQ(v.to_deprecated_string(), "true"sv);
|
||||
EXPECT_EQ(v.to_byte_string(), "true"sv);
|
||||
|
||||
EXPECT(v.to_double().has_value());
|
||||
EXPECT((v.to_double().value() - 1.0) < NumericLimits<double>().epsilon());
|
||||
|
|
|
@ -24,14 +24,14 @@ static ByteBuffer operator""_b(char const* string, size_t length)
|
|||
}
|
||||
|
||||
ErrorOr<Vector<Certificate>> load_certificates();
|
||||
DeprecatedString locate_ca_certs_file();
|
||||
ByteString locate_ca_certs_file();
|
||||
|
||||
DeprecatedString locate_ca_certs_file()
|
||||
ByteString locate_ca_certs_file()
|
||||
{
|
||||
if (FileSystem::exists(ca_certs_file)) {
|
||||
return ca_certs_file;
|
||||
}
|
||||
auto on_target_path = DeprecatedString("/etc/cacert.pem");
|
||||
auto on_target_path = ByteString("/etc/cacert.pem");
|
||||
if (FileSystem::exists(on_target_path)) {
|
||||
return on_target_path;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile)
|
|||
return StringView { error_string, strlen(error_string) };
|
||||
};
|
||||
|
||||
auto filename = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto filename = TRY(vm.argument(0).to_byte_string(vm));
|
||||
auto file = Core::File::open(filename, Core::File::OpenMode::Read);
|
||||
if (file.is_error())
|
||||
return vm.throw_completion<JS::TypeError>(error_code_to_string(file.error().code()));
|
||||
|
@ -114,7 +114,7 @@ TESTJS_GLOBAL_FUNCTION(parse_webassembly_module, parseWebAssemblyModule)
|
|||
FixedMemoryStream stream { array.data() };
|
||||
auto result = Wasm::Module::parse(stream);
|
||||
if (result.is_error())
|
||||
return vm.throw_completion<JS::SyntaxError>(Wasm::parse_error_to_deprecated_string(result.error()));
|
||||
return vm.throw_completion<JS::SyntaxError>(Wasm::parse_error_to_byte_string(result.error()));
|
||||
|
||||
HashMap<Wasm::Linker::Name, Wasm::ExternValue> imports;
|
||||
auto import_value = vm.argument(1);
|
||||
|
@ -157,7 +157,7 @@ void WebAssemblyModule::initialize(JS::Realm& realm)
|
|||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
|
||||
{
|
||||
auto name = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto name = TRY(vm.argument(0).to_byte_string(vm));
|
||||
auto this_value = vm.this_value();
|
||||
auto object = TRY(this_value.to_object(vm));
|
||||
if (!is<WebAssemblyModule>(*object))
|
||||
|
|
|
@ -234,7 +234,7 @@ TEST_CASE(regression)
|
|||
auto file_size = MUST(file->size());
|
||||
auto content = MUST(ByteBuffer::create_uninitialized(file_size));
|
||||
MUST(file->read_until_filled(content.bytes()));
|
||||
DeprecatedString file_contents { content.bytes() };
|
||||
ByteString file_contents { content.bytes() };
|
||||
auto tokens = run_tokenizer(file_contents);
|
||||
u32 hash = hash_tokens(tokens);
|
||||
EXPECT_EQ(hash, 3657343287u);
|
||||
|
|
|
@ -15,13 +15,13 @@ 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(DeprecatedString const&, JS::Realm& realm, JS::ExecutionContext& global_execution_context)
|
||||
TESTJS_RUN_FILE_FUNCTION(ByteString const&, JS::Realm& realm, JS::ExecutionContext& global_execution_context)
|
||||
{
|
||||
auto run_file = [&](StringView name) {
|
||||
auto result = Test::JS::parse_script(name, realm);
|
||||
if (result.is_error()) {
|
||||
warnln("Unable to parse {}", name);
|
||||
warnln("{}", result.error().error.to_deprecated_string());
|
||||
warnln("{}", result.error().error.to_byte_string());
|
||||
warnln("{}", result.error().hint);
|
||||
Test::cleanup_and_exit();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ static void run_sed(Vector<char const*>&& arguments, StringView standard_input,
|
|||
auto [stdout, stderr] = MUST(sed->read_all());
|
||||
auto status = MUST(sed->status());
|
||||
if (status != Core::Command::ProcessResult::DoneWithZeroExitCode) {
|
||||
FAIL(DeprecatedString::formatted("sed didn't exit cleanly: status: {}, stdout:{}, stderr: {}", static_cast<int>(status), StringView { stdout.bytes() }, StringView { stderr.bytes() }));
|
||||
FAIL(ByteString::formatted("sed didn't exit cleanly: status: {}, stdout:{}, stderr: {}", static_cast<int>(status), StringView { stdout.bytes() }, StringView { stderr.bytes() }));
|
||||
}
|
||||
EXPECT_EQ(StringView { expected_stdout.bytes() }, StringView { stdout.bytes() });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue