summaryrefslogtreecommitdiff
path: root/AK/Tests
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-07 15:05:10 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-07 15:05:10 +0200
commite8e85f5457a225f6387efdf1f4d9f36f93fce3fb (patch)
tree96cc851f56b59e724b1496d71e63a4bd1daa41e4 /AK/Tests
parent6d97caf124ffca77dd3b829dfef3de55f073c62e (diff)
downloadserenity-e8e85f5457a225f6387efdf1f4d9f36f93fce3fb.zip
Vector: Use memcmp for comparing two vectors with trivial elements
Diffstat (limited to 'AK/Tests')
-rw-r--r--AK/Tests/TestVector.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/AK/Tests/TestVector.cpp b/AK/Tests/TestVector.cpp
index 1405ccfb4a..88a53ba9fe 100644
--- a/AK/Tests/TestVector.cpp
+++ b/AK/Tests/TestVector.cpp
@@ -142,4 +142,29 @@ TEST_CASE(prepend_vector_object)
EXPECT_EQ(objects[5].subobject->value, 3);
}
+TEST_CASE(vector_compare)
+{
+ Vector<int> ints;
+ Vector<int> same_ints;
+
+ for (int i = 0; i < 1000; ++i) {
+ ints.append(i);
+ same_ints.append(i);
+ }
+
+ EXPECT_EQ(ints.size(), 1000);
+ EXPECT_EQ(ints, same_ints);
+
+ Vector<String> strings;
+ Vector<String> same_strings;
+
+ for (int i = 0; i < 1000; ++i) {
+ strings.append(String::number(i));
+ same_strings.append(String::number(i));
+ }
+
+ EXPECT_EQ(strings.size(), 1000);
+ EXPECT_EQ(strings, same_strings);
+}
+
TEST_MAIN(Vector)