AK/Tests: Test Queue<String> with large number of elements.

This commit is contained in:
Andreas Kling 2019-06-15 10:39:19 +02:00
parent c699d9d79d
commit bfaa74f076
Notes: sideshowbarker 2024-07-19 13:36:09 +09:00
2 changed files with 23 additions and 10 deletions

1
AK/Tests/.gitignore vendored
View file

@ -1 +1,2 @@
TestString
TestQueue

View file

@ -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;