diff options
author | Linus Groh <mail@linusgroh.de> | 2022-12-04 18:02:33 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-06 08:54:33 +0100 |
commit | 6e19ab2bbce0b113b628e6f8e9b5c0640053933e (patch) | |
tree | 372d21b2f5dcff112f5d0089559c6af5798680d4 /Tests/AK/TestVariant.cpp | |
parent | f74251606d74b504a1379ebb893fdb5529054ea5 (diff) | |
download | serenity-6e19ab2bbce0b113b628e6f8e9b5c0640053933e.zip |
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
Diffstat (limited to 'Tests/AK/TestVariant.cpp')
-rw-r--r-- | Tests/AK/TestVariant.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/Tests/AK/TestVariant.cpp b/Tests/AK/TestVariant.cpp index ea7998a099..37bbf646cd 100644 --- a/Tests/AK/TestVariant.cpp +++ b/Tests/AK/TestVariant.cpp @@ -18,21 +18,21 @@ struct Object : public RefCounted<Object> { TEST_CASE(basic) { - Variant<int, String> the_value { 42 }; + Variant<int, DeprecatedString> the_value { 42 }; EXPECT(the_value.has<int>()); EXPECT_EQ(the_value.get<int>(), 42); - the_value = String("42"); - EXPECT(the_value.has<String>()); - EXPECT_EQ(the_value.get<String>(), "42"); + the_value = DeprecatedString("42"); + EXPECT(the_value.has<DeprecatedString>()); + EXPECT_EQ(the_value.get<DeprecatedString>(), "42"); } TEST_CASE(visit) { bool correct = false; - Variant<int, String, float> the_value { 42.0f }; + Variant<int, DeprecatedString, float> the_value { 42.0f }; the_value.visit( [&](int const&) { correct = false; }, - [&](String const&) { correct = false; }, + [&](DeprecatedString const&) { correct = false; }, [&](float const&) { correct = true; }); EXPECT(correct); } @@ -40,10 +40,10 @@ TEST_CASE(visit) TEST_CASE(visit_const) { bool correct = false; - Variant<int, String> const the_value { "42"sv }; + Variant<int, DeprecatedString> const the_value { "42"sv }; the_value.visit( - [&](String const&) { correct = true; }, + [&](DeprecatedString const&) { correct = true; }, [&](auto&) {}, [&](auto const&) {}); @@ -52,7 +52,7 @@ TEST_CASE(visit_const) correct = false; auto the_value_but_not_const = the_value; the_value_but_not_const.visit( - [&](String const&) { correct = true; }, + [&](DeprecatedString const&) { correct = true; }, [&](auto&) {}); EXPECT(correct); @@ -168,13 +168,13 @@ TEST_CASE(duplicated_types) TEST_CASE(return_values) { - using MyVariant = Variant<int, String, float>; + using MyVariant = Variant<int, DeprecatedString, float>; { MyVariant the_value { 42.0f }; float value = the_value.visit( [&](int const&) { return 1.0f; }, - [&](String const&) { return 2.0f; }, + [&](DeprecatedString const&) { return 2.0f; }, [&](float const& f) { return f; }); EXPECT_EQ(value, 42.0f); } @@ -183,17 +183,17 @@ TEST_CASE(return_values) int value = the_value.visit( [&](int& i) { return i; }, - [&](String&) { return 2; }, + [&](DeprecatedString&) { return 2; }, [&](float&) { return 3; }); EXPECT_EQ(value, 42); } { const MyVariant the_value { "str" }; - String value = the_value.visit( - [&](int const&) { return String { "wrong" }; }, - [&](String const& s) { return s; }, - [&](float const&) { return String { "wrong" }; }); + DeprecatedString value = the_value.visit( + [&](int const&) { return DeprecatedString { "wrong" }; }, + [&](DeprecatedString const& s) { return s; }, + [&](float const&) { return DeprecatedString { "wrong" }; }); EXPECT_EQ(value, "str"); } } @@ -201,11 +201,11 @@ TEST_CASE(return_values) TEST_CASE(return_values_by_reference) { auto ref = adopt_ref_if_nonnull(new (nothrow) Object()); - Variant<int, String, float> the_value { 42.0f }; + Variant<int, DeprecatedString, float> the_value { 42.0f }; auto& value = the_value.visit( [&](int const&) -> RefPtr<Object>& { return ref; }, - [&](String const&) -> RefPtr<Object>& { return ref; }, + [&](DeprecatedString const&) -> RefPtr<Object>& { return ref; }, [&](float const&) -> RefPtr<Object>& { return ref; }); EXPECT_EQ(ref, value); @@ -223,7 +223,7 @@ struct HoldsFloat { TEST_CASE(copy_assign) { { - Variant<int, String, float> the_value { 42.0f }; + Variant<int, DeprecatedString, float> the_value { 42.0f }; VERIFY(the_value.has<float>()); EXPECT_EQ(the_value.get<float>(), 42.0f); @@ -233,12 +233,12 @@ TEST_CASE(copy_assign) VERIFY(the_value.has<int>()); EXPECT_EQ(the_value.get<int>(), 12); - the_value = String("Hello, world!"); - VERIFY(the_value.has<String>()); - EXPECT_EQ(the_value.get<String>(), "Hello, world!"); + the_value = DeprecatedString("Hello, world!"); + VERIFY(the_value.has<DeprecatedString>()); + EXPECT_EQ(the_value.get<DeprecatedString>(), "Hello, world!"); } { - Variant<HoldsInt, String, HoldsFloat> the_value { HoldsFloat { 42.0f } }; + Variant<HoldsInt, DeprecatedString, HoldsFloat> the_value { HoldsFloat { 42.0f } }; VERIFY(the_value.has<HoldsFloat>()); EXPECT_EQ(the_value.get<HoldsFloat>().f, 42.0f); @@ -248,9 +248,9 @@ TEST_CASE(copy_assign) VERIFY(the_value.has<HoldsInt>()); EXPECT_EQ(the_value.get<HoldsInt>().i, 12); - the_value = String("Hello, world!"); - VERIFY(the_value.has<String>()); - EXPECT_EQ(the_value.get<String>(), "Hello, world!"); + the_value = DeprecatedString("Hello, world!"); + VERIFY(the_value.has<DeprecatedString>()); + EXPECT_EQ(the_value.get<DeprecatedString>(), "Hello, world!"); } } |