mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
AK/Tests: Test Queue<String> with large number of elements.
This commit is contained in:
parent
c699d9d79d
commit
bfaa74f076
Notes:
sideshowbarker
2024-07-19 13:36:09 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/bfaa74f0769
2 changed files with 23 additions and 10 deletions
1
AK/Tests/.gitignore
vendored
1
AK/Tests/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
TestString
|
||||
TestQueue
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue