mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
AK/Tests: Test Queue<String> with large number of elements.
This commit is contained in:
parent
c699d9d79d
commit
bfaa74f076
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