1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +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:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -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");