mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:08:10 +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:
parent
df3e295ba6
commit
41d2c674d7
8 changed files with 386 additions and 136 deletions
|
@ -1,12 +1,15 @@
|
|||
#include "TestHelpers.h"
|
||||
#include <AK/TestSuite.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
int main()
|
||||
TEST_CASE(construct)
|
||||
{
|
||||
EXPECT(Vector<int>().is_empty());
|
||||
EXPECT(Vector<int>().size() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE(ints)
|
||||
{
|
||||
Vector<int> ints;
|
||||
ints.append(1);
|
||||
ints.append(2);
|
||||
|
@ -21,7 +24,10 @@ int main()
|
|||
|
||||
ints.clear();
|
||||
EXPECT_EQ(ints.size(), 0);
|
||||
}
|
||||
|
||||
TEST_CASE(strings)
|
||||
{
|
||||
Vector<String> strings;
|
||||
strings.append("ABC");
|
||||
strings.append("DEF");
|
||||
|
@ -40,22 +46,23 @@ int main()
|
|||
++loop_counter;
|
||||
}
|
||||
EXPECT_EQ(loop_counter, 2);
|
||||
|
||||
{
|
||||
Vector<String> strings;
|
||||
strings.append("abc");
|
||||
strings.append("def");
|
||||
strings.append("ghi");
|
||||
|
||||
strings.insert_before_matching("f-g", [](auto& entry) {
|
||||
return "f-g" < entry;
|
||||
});
|
||||
|
||||
EXPECT_EQ(strings[0], "abc");
|
||||
EXPECT_EQ(strings[1], "def");
|
||||
EXPECT_EQ(strings[2], "f-g");
|
||||
EXPECT_EQ(strings[3], "ghi");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_CASE(strings_insert_ordered)
|
||||
{
|
||||
Vector<String> strings;
|
||||
strings.append("abc");
|
||||
strings.append("def");
|
||||
strings.append("ghi");
|
||||
|
||||
strings.insert_before_matching("f-g", [](auto& entry) {
|
||||
return "f-g" < entry;
|
||||
});
|
||||
|
||||
EXPECT_EQ(strings[0], "abc");
|
||||
EXPECT_EQ(strings[1], "def");
|
||||
EXPECT_EQ(strings[2], "f-g");
|
||||
EXPECT_EQ(strings[3], "ghi");
|
||||
}
|
||||
|
||||
TEST_MAIN(Vector)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue