test_string.cpp
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
37
38
39
40
41
#include "crucible/core.hpp" #include "crucible/test.hpp" namespace test_string { static char const UTF8_SMALL_TEXT_DATA[] { "g\U000000e2teau \U0001f382 \U00002713" }; static auto const UTF8_SMALL_TEXT_VIEW { crucible::make_immutable_view_from_cstring(UTF8_SMALL_TEXT_DATA) }; static auto const UTF8_SMALL_TEXT_STRING { crucible::make_string(UTF8_SMALL_TEXT_VIEW) }; static auto const UTF8_SMALL_TEXT_STRING_VIEW { crucible::make_string_view(UTF8_SMALL_TEXT_VIEW) }; CRUCIBLE_SCENARIO(string, empty_string) { crucible::String const string {}; CRUCIBLE_EXPECT_PROPERTY(string.is_empty(), string); } CRUCIBLE_SCENARIO(string, string_has_prefix) { CRUCIBLE_EXPECT(UTF8_SMALL_TEXT_STRING.has_prefix("g\U000000e2")); } CRUCIBLE_SCENARIO(string, string_has_suffix) { CRUCIBLE_EXPECT(UTF8_SMALL_TEXT_STRING.has_suffix(" \U0001f382 \U00002713")); } CRUCIBLE_SCENARIO(string, string_view_has_prefix) { CRUCIBLE_EXPECT(UTF8_SMALL_TEXT_STRING_VIEW.has_prefix("g\U000000e2")); } CRUCIBLE_SCENARIO(string, string_view_has_suffix) { CRUCIBLE_EXPECT(UTF8_SMALL_TEXT_STRING_VIEW.has_suffix(" \U0001f382 \U00002713")); } } CRUCIBLE_BOOT(crucible::test::shell)