1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

AK: Add a new TestSuite.h from my own work, adapted to match the existing one a bit

This gives a few new features:

* benchmarks
* the ability to run individual testcases easily
* timing of tests
This commit is contained in:
Robin Burchell 2019-07-16 10:08:39 +02:00 committed by Andreas Kling
parent df3e295ba6
commit 41d2c674d7
8 changed files with 386 additions and 136 deletions

View file

@ -1,12 +1,15 @@
#include "TestHelpers.h"
#include <AK/TestSuite.h>
#include <AK/AKString.h>
#include <AK/Queue.h>
int main()
TEST_CASE(construct)
{
EXPECT(Queue<int>().is_empty());
EXPECT(Queue<int>().size() == 0);
}
TEST_CASE(populate_int)
{
Queue<int> ints;
ints.enqueue(1);
ints.enqueue(2);
@ -18,7 +21,10 @@ int main()
EXPECT_EQ(ints.size(), 1);
EXPECT_EQ(ints.dequeue(), 3);
EXPECT_EQ(ints.size(), 0);
}
TEST_CASE(populate_string)
{
Queue<String> strings;
strings.enqueue("ABC");
strings.enqueue("DEF");
@ -26,6 +32,12 @@ int main()
EXPECT_EQ(strings.dequeue(), "ABC");
EXPECT_EQ(strings.dequeue(), "DEF");
EXPECT(strings.is_empty());
}
TEST_CASE(order)
{
Queue<String> strings;
EXPECT(strings.is_empty());
for (int i = 0; i < 10000; ++i) {
strings.enqueue(String::number(i));
@ -38,6 +50,6 @@ int main()
}
EXPECT(strings.is_empty());
return 0;
}
TEST_MAIN(Queue)