summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorMaciej <sppmacd@pm.me>2022-12-08 18:30:04 +0100
committerAndreas Kling <kling@serenityos.org>2022-12-09 00:02:53 +0100
commit58f5deba70c0e9d21836fda4b1fee041fef69e16 (patch)
tree1edc7537662f17ba9c2e78b177e2313ae9059cb7 /Tests
parent741138c5850d5c32a0558d96a1e6f6f92c70e4b1 (diff)
downloadserenity-58f5deba70c0e9d21836fda4b1fee041fef69e16.zip
AK: Unref old m_data in String's move assignment
We were overridding the data pointer without unreffing it, causing a memory leak when assigning a String.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/AK/TestString.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Tests/AK/TestString.cpp b/Tests/AK/TestString.cpp
index c453e6d74c..3cc88317a9 100644
--- a/Tests/AK/TestString.cpp
+++ b/Tests/AK/TestString.cpp
@@ -24,6 +24,13 @@ TEST_CASE(construct_empty)
EXPECT_EQ(empty, ""sv);
}
+TEST_CASE(move_assignment)
+{
+ String string1 = MUST(String::from_utf8("hello"sv));
+ string1 = MUST(String::from_utf8("friends!"sv));
+ EXPECT_EQ(string1, "friends!"sv);
+}
+
TEST_CASE(short_strings)
{
#ifdef AK_ARCH_64_BIT