summaryrefslogtreecommitdiff
path: root/AK/Tests
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-15 10:39:19 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-15 10:39:19 +0200
commitbfaa74f0769edd54b3c1f9ff5e1b0b0ccc3d6b69 (patch)
tree0cfbe11176dd5949f7af26df43cb5aab5fc00e01 /AK/Tests
parentc699d9d79dff8fae121ba52f83f7c59dfa0b52d8 (diff)
downloadserenity-bfaa74f0769edd54b3c1f9ff5e1b0b0ccc3d6b69.zip
AK/Tests: Test Queue<String> with large number of elements.
Diffstat (limited to 'AK/Tests')
-rw-r--r--AK/Tests/.gitignore1
-rw-r--r--AK/Tests/TestQueue.cpp32
2 files changed, 23 insertions, 10 deletions
diff --git a/AK/Tests/.gitignore b/AK/Tests/.gitignore
index 3a62d28e3c..2e42a5a41c 100644
--- a/AK/Tests/.gitignore
+++ b/AK/Tests/.gitignore
@@ -1 +1,2 @@
TestString
+TestQueue
diff --git a/AK/Tests/TestQueue.cpp b/AK/Tests/TestQueue.cpp
index b5496c052a..708835f154 100644
--- a/AK/Tests/TestQueue.cpp
+++ b/AK/Tests/TestQueue.cpp
@@ -11,20 +11,32 @@ int main()
ints.enqueue(1);
ints.enqueue(2);
ints.enqueue(3);
- EXPECT(ints.size() == 3);
- EXPECT(ints.dequeue() == 1);
- EXPECT(ints.size() == 2);
- EXPECT(ints.dequeue() == 2);
- EXPECT(ints.size() == 1);
- EXPECT(ints.dequeue() == 3);
- EXPECT(ints.size() == 0);
+ EXPECT_EQ(ints.size(), 3);
+ EXPECT_EQ(ints.dequeue(), 1);
+ EXPECT_EQ(ints.size(), 2);
+ EXPECT_EQ(ints.dequeue(), 2);
+ EXPECT_EQ(ints.size(), 1);
+ EXPECT_EQ(ints.dequeue(), 3);
+ EXPECT_EQ(ints.size(), 0);
Queue<String> strings;
strings.enqueue("ABC");
strings.enqueue("DEF");
- EXPECT(strings.size() == 2);
- EXPECT(strings.dequeue() == "ABC");
- EXPECT(strings.dequeue() == "DEF");
+ EXPECT_EQ(strings.size(), 2);
+ EXPECT_EQ(strings.dequeue(), "ABC");
+ EXPECT_EQ(strings.dequeue(), "DEF");
+ EXPECT(strings.is_empty());
+
+ for (int i = 0; i < 10000; ++i) {
+ strings.enqueue(String::format("%d", i));
+ EXPECT_EQ(strings.size(), i + 1);
+ }
+
+ for (int i = 0; i < 10000; ++i) {
+ bool ok;
+ EXPECT_EQ(strings.dequeue().to_int(ok), i);
+ }
+
EXPECT(strings.is_empty());
return 0;