blob: 87d35263a3f9d5b34bbe4330878bd5cf950d851f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <AK/TestSuite.h>
#include <AK/String.h>
TEST_CASE(construct_empty)
{
EXPECT(StringView().is_null());
EXPECT(StringView().is_empty());
EXPECT(!StringView().characters_without_null_termination());
EXPECT_EQ(StringView().length(), 0);
}
TEST_CASE(view_literal)
{
const char* truth = "cats rule dogs drool";
StringView view(truth);
EXPECT_EQ(view.is_null(), false);
EXPECT_EQ(view.characters_without_null_termination(), truth);
EXPECT_EQ(view, view);
EXPECT_EQ(view, truth);
}
TEST_CASE(compare_views)
{
String foo1 = "foo";
String foo2 = "foo";
auto view1 = foo1.view();
auto view2 = foo2.view();
EXPECT_EQ(view1, view2);
EXPECT_EQ(view1, foo1);
EXPECT_EQ(view1, foo2);
EXPECT_EQ(view1, "foo");
}
TEST_MAIN(StringView)
|