diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-06-15 10:39:19 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-06-15 10:39:19 +0200 |
commit | bfaa74f0769edd54b3c1f9ff5e1b0b0ccc3d6b69 (patch) | |
tree | 0cfbe11176dd5949f7af26df43cb5aab5fc00e01 /AK/Tests | |
parent | c699d9d79dff8fae121ba52f83f7c59dfa0b52d8 (diff) | |
download | serenity-bfaa74f0769edd54b3c1f9ff5e1b0b0ccc3d6b69.zip |
AK/Tests: Test Queue<String> with large number of elements.
Diffstat (limited to 'AK/Tests')
-rw-r--r-- | AK/Tests/.gitignore | 1 | ||||
-rw-r--r-- | AK/Tests/TestQueue.cpp | 32 |
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; |