mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
AK/Tests: Add a simple EXPECT_EQ macro and use it for the String test.
This commit is contained in:
parent
3557f277f6
commit
a12751695e
3 changed files with 60 additions and 11 deletions
|
@ -16,8 +16,8 @@ int main()
|
|||
String test_string = "ABCDEF";
|
||||
EXPECT(!test_string.is_empty());
|
||||
EXPECT(!test_string.is_null());
|
||||
EXPECT(test_string.length() == 6);
|
||||
EXPECT(test_string.length() == (int)strlen(test_string.characters()));
|
||||
EXPECT_EQ(test_string.length(), 6);
|
||||
EXPECT_EQ(test_string.length(), (int)strlen(test_string.characters()));
|
||||
EXPECT(test_string.characters());
|
||||
EXPECT(!strcmp(test_string.characters(), "ABCDEF"));
|
||||
|
||||
|
@ -25,8 +25,8 @@ int main()
|
|||
EXPECT(test_string != "ABCDE");
|
||||
EXPECT(test_string != "ABCDEFG");
|
||||
|
||||
EXPECT(test_string[0] == 'A');
|
||||
EXPECT(test_string[1] == 'B');
|
||||
EXPECT_EQ(test_string[0], 'A');
|
||||
EXPECT_EQ(test_string[1], 'B');
|
||||
|
||||
EXPECT(test_string.starts_with("AB"));
|
||||
EXPECT(test_string.starts_with("ABCDEF"));
|
||||
|
@ -37,16 +37,16 @@ int main()
|
|||
EXPECT(!test_string.ends_with("ABC"));
|
||||
|
||||
auto test_string_copy = test_string;
|
||||
EXPECT(test_string == test_string_copy);
|
||||
EXPECT(test_string.characters() == test_string_copy.characters());
|
||||
EXPECT_EQ(test_string, test_string_copy);
|
||||
EXPECT_EQ(test_string.characters(), test_string_copy.characters());
|
||||
|
||||
auto test_string_move = move(test_string_copy);
|
||||
EXPECT(test_string == test_string_move);
|
||||
EXPECT_EQ(test_string, test_string_move);
|
||||
EXPECT(test_string_copy.is_null());
|
||||
|
||||
EXPECT(String::repeated('x', 0) == "");
|
||||
EXPECT(String::repeated('x', 1) == "x");
|
||||
EXPECT(String::repeated('x', 2) == "xx");
|
||||
EXPECT_EQ(String::repeated('x', 0), "");
|
||||
EXPECT_EQ(String::repeated('x', 1), "x");
|
||||
EXPECT_EQ(String::repeated('x', 2), "xx");
|
||||
|
||||
bool ok;
|
||||
EXPECT(String("123").to_int(ok) == 123 && ok);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue