summaryrefslogtreecommitdiff
path: root/Tests/AK/TestHashMap.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-04 18:02:33 +0000
committerAndreas Kling <kling@serenityos.org>2022-12-06 08:54:33 +0100
commit6e19ab2bbce0b113b628e6f8e9b5c0640053933e (patch)
tree372d21b2f5dcff112f5d0089559c6af5798680d4 /Tests/AK/TestHashMap.cpp
parentf74251606d74b504a1379ebb893fdb5529054ea5 (diff)
downloadserenity-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/TestHashMap.cpp')
-rw-r--r--Tests/AK/TestHashMap.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/Tests/AK/TestHashMap.cpp b/Tests/AK/TestHashMap.cpp
index 8d46a3d612..a6b5d2dea2 100644
--- a/Tests/AK/TestHashMap.cpp
+++ b/Tests/AK/TestHashMap.cpp
@@ -6,9 +6,9 @@
#include <LibTest/TestCase.h>
+#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
-#include <AK/String.h>
TEST_CASE(construct)
{
@@ -19,7 +19,7 @@ TEST_CASE(construct)
TEST_CASE(construct_from_initializer_list)
{
- HashMap<int, String> number_to_string {
+ HashMap<int, DeprecatedString> number_to_string {
{ 1, "One" },
{ 2, "Two" },
{ 3, "Three" },
@@ -30,7 +30,7 @@ TEST_CASE(construct_from_initializer_list)
TEST_CASE(populate)
{
- HashMap<int, String> number_to_string;
+ HashMap<int, DeprecatedString> number_to_string;
number_to_string.set(1, "One");
number_to_string.set(2, "Two");
number_to_string.set(3, "Three");
@@ -41,7 +41,7 @@ TEST_CASE(populate)
TEST_CASE(range_loop)
{
- HashMap<int, String> number_to_string;
+ HashMap<int, DeprecatedString> number_to_string;
EXPECT_EQ(number_to_string.set(1, "One"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(number_to_string.set(2, "Two"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(number_to_string.set(3, "Three"), AK::HashSetResult::InsertedNewEntry);
@@ -56,7 +56,7 @@ TEST_CASE(range_loop)
TEST_CASE(map_remove)
{
- HashMap<int, String> number_to_string;
+ HashMap<int, DeprecatedString> number_to_string;
EXPECT_EQ(number_to_string.set(1, "One"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(number_to_string.set(2, "Two"), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(number_to_string.set(3, "Three"), AK::HashSetResult::InsertedNewEntry);
@@ -73,7 +73,7 @@ TEST_CASE(map_remove)
TEST_CASE(remove_all_matching)
{
- HashMap<int, String> map;
+ HashMap<int, DeprecatedString> map;
map.set(1, "One");
map.set(2, "Two");
@@ -82,27 +82,27 @@ TEST_CASE(remove_all_matching)
EXPECT_EQ(map.size(), 4u);
- EXPECT_EQ(map.remove_all_matching([&](int key, String const& value) { return key == 1 || value == "Two"; }), true);
+ EXPECT_EQ(map.remove_all_matching([&](int key, DeprecatedString const& value) { return key == 1 || value == "Two"; }), true);
EXPECT_EQ(map.size(), 2u);
- EXPECT_EQ(map.remove_all_matching([&](int, String const&) { return false; }), false);
+ EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return false; }), false);
EXPECT_EQ(map.size(), 2u);
EXPECT(map.contains(3));
EXPECT(map.contains(4));
- EXPECT_EQ(map.remove_all_matching([&](int, String const&) { return true; }), true);
- EXPECT_EQ(map.remove_all_matching([&](int, String const&) { return false; }), false);
+ EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return true; }), true);
+ EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return false; }), false);
EXPECT(map.is_empty());
- EXPECT_EQ(map.remove_all_matching([&](int, String const&) { return true; }), false);
+ EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return true; }), false);
}
TEST_CASE(case_insensitive)
{
- HashMap<String, int, CaseInsensitiveStringTraits> casemap;
- EXPECT_EQ(String("nickserv").to_lowercase(), String("NickServ").to_lowercase());
+ HashMap<DeprecatedString, int, CaseInsensitiveStringTraits> casemap;
+ EXPECT_EQ(DeprecatedString("nickserv").to_lowercase(), DeprecatedString("NickServ").to_lowercase());
EXPECT_EQ(casemap.set("nickserv", 3), AK::HashSetResult::InsertedNewEntry);
EXPECT_EQ(casemap.set("NickServ", 3), AK::HashSetResult::ReplacedExistingEntry);
EXPECT_EQ(casemap.size(), 1u);
@@ -111,11 +111,11 @@ TEST_CASE(case_insensitive)
TEST_CASE(hashmap_of_nonnullownptr_get)
{
struct Object {
- Object(String const& s)
+ Object(DeprecatedString const& s)
: string(s)
{
}
- String string;
+ DeprecatedString string;
};
HashMap<int, NonnullOwnPtr<Object>> objects;
@@ -142,16 +142,16 @@ TEST_CASE(hashmap_of_nonnullownptr_get)
TEST_CASE(many_strings)
{
- HashMap<String, int> strings;
+ HashMap<DeprecatedString, int> strings;
for (int i = 0; i < 999; ++i) {
- EXPECT_EQ(strings.set(String::number(i), i), AK::HashSetResult::InsertedNewEntry);
+ EXPECT_EQ(strings.set(DeprecatedString::number(i), i), AK::HashSetResult::InsertedNewEntry);
}
EXPECT_EQ(strings.size(), 999u);
for (auto& it : strings) {
EXPECT_EQ(it.key.to_int().value(), it.value);
}
for (int i = 0; i < 999; ++i) {
- EXPECT_EQ(strings.remove(String::number(i)), true);
+ EXPECT_EQ(strings.remove(DeprecatedString::number(i)), true);
}
EXPECT_EQ(strings.is_empty(), true);
}
@@ -204,7 +204,7 @@ TEST_CASE(basic_contains)
TEST_CASE(in_place_rehashing_ordered_loop_bug)
{
- OrderedHashMap<String, String> map;
+ OrderedHashMap<DeprecatedString, DeprecatedString> map;
map.set("yt.innertube::nextId", "");
map.set("yt.innertube::requests", "");
map.remove("yt.innertube::nextId");