mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:37:44 +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
|
@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue