From bfaa74f0769edd54b3c1f9ff5e1b0b0ccc3d6b69 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 15 Jun 2019 10:39:19 +0200 Subject: AK/Tests: Test Queue with large number of elements. --- AK/Tests/.gitignore | 1 + AK/Tests/TestQueue.cpp | 32 ++++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'AK/Tests') 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 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; -- cgit v1.2.3