xref: /llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/main.cpp (revision 487ab39a5082098f92e886de606505f25031a22a)
1 #include <stdint.h>
2 #include <string>
3 #include <string_view>
4 
touch_string(std::string_view & in_str_view)5 static size_t touch_string(std::string_view &in_str_view) {
6   return in_str_view.size(); // Break here to look at bad string view.
7 }
8 
main()9 int main() {
10   std::wstring_view wempty(L"");
11   std::wstring_view s(L"hello world! מזל טוב!");
12   std::wstring_view S(L"!!!!");
13   std::string_view empty("");
14   std::string q_source = "hello world";
15   std::string_view q(q_source);
16   std::string_view Q("quite a long std::strin with lots of info inside it");
17   std::string_view TheVeryLongOne(
18       "123456789012345678901234567890123456789012345678901234567890123456789012"
19       "345678901234567890123456789012345678901234567890123456789012345678901234"
20       "567890123456789012345678901234567890123456789012345678901234567890123456"
21       "789012345678901234567890123456789012345678901234567890123456789012345678"
22       "901234567890123456789012345678901234567890123456789012345678901234567890"
23       "123456789012345678901234567890123456789012345678901234567890123456789012"
24       "345678901234567890123456789012345678901234567890123456789012345678901234"
25       "567890123456789012345678901234567890123456789012345678901234567890123456"
26       "789012345678901234567890123456789012345678901234567890123456789012345678"
27       "901234567890123456789012345678901234567890123456789012345678901234567890"
28       "123456789012345678901234567890123456789012345678901234567890123456789012"
29       "345678901234567890123456789012345678901234567890123456789012345678901234"
30       "567890123456789012345678901234567890123456789012345678901234567890123456"
31       "789012345678901234567890123456789012345678901234567890123456789012345678"
32       "901234567890123456789012345678901234567890123456789012345678901234567890"
33       "123456789012345678901234567890123456789012345678901234567890123456789012"
34       "345678901234567890123456789012345678901234567890123456789012345678901234"
35       "567890123456789012345678901234567890123456789012345678901234567890123456"
36       "789012345678901234567890123456789012345678901234567890123456789012345678"
37       "901234567890123456789012345678901234567890123456789012345678901234567890"
38       "123456789012345678901234567890123456789012345678901234567890123456789012"
39       "345678901234567890123456789012345678901234567890123456789012345678901234"
40       "567890123456789012345678901234567890123456789012345678901234567890123456"
41       "789012345678901234567890123456789012345678901234567890123456789012345678"
42       "901234567890123456789012345678901234567890123456789012345678901234567890"
43       "123456789012345678901234567890123456789012345678901234567890123456789012"
44       "345678901234567890123456789012345678901234567890123456789012345678901234"
45       "567890123456789012345678901234567890123456789012345678901234567890123456"
46       "789012345678901234567890123456789012345678901234567890123456789012345678"
47       "901234567890123456789012345678901234567890123456789012345678901234567890"
48       "123456789012345678901234567890123456789012345678901234567890123456789012"
49       "345678901234567890123456789012345678901234567890123456789012345678901234"
50       "567890123456789012345678901234567890123456789012345678901234567890123456"
51       "789012345678901234567890123456789012345678901234567890123456789012345678"
52       "9012345678901234567890123456789012345678901234567890someText123456789012"
53       "345678901234567890123456789012345678901234567890123456789012345678901234"
54       "567890123456789012345678901234567890123456789012345678901234567890123456"
55       "789012345678901234567890123456789012345678901234567890123456789012345678"
56       "901234567890123456789012345678901234567890123456789012345678901234567890"
57       "123456789012345678901234567890123456789012345678901234567890123456789012"
58       "345678901234567890123456789012345678901234567890123456789012345678901234"
59       "567890123456789012345678901234567890123456789012345678901234567890123456"
60       "789012345678901234567890123456789012345678901234567890123456789012345678"
61       "901234567890123456789012345678901234567890123456789012345678901234567890"
62       "123456789012345678901234567890123456789012345678901234567890123456789012"
63       "345678901234567890123456789012345678901234567890123456789012345678901234"
64       "567890123456789012345678901234567890123456789012345678901234567890123456"
65       "789012345678901234567890123456789012345678901234567890123456789012345678"
66       "901234567890123456789012345678901234567890123456789012345678901234567890"
67       "123456789012345678901234567890123456789012345678901234567890123456789012"
68       "345678901234567890123456789012345678901234567890123456789012345678901234"
69       "567890123456789012345678901234567890123456789012345678901234567890123456"
70       "789012345678901234567890123456789012345678901234567890123456789012345678"
71       "901234567890123456789012345678901234567890123456789012345678901234567890"
72       "123456789012345678901234567890123456789012345678901234567890123456789012"
73       "345678901234567890123456789012345678901234567890123456789012345678901234"
74       "567890123456789012345678901234567890123456789012345678901234567890123456"
75       "789012345678901234567890123456789012345678901234567890123456789012345678"
76       "901234567890123456789012345678901234567890123456789012345678901234567890"
77       "123456789012345678901234567890123456789012345678901234567890123456789012"
78       "345678901234567890123456789012345678901234567890123456789012345678901234"
79       "567890123456789012345678901234567890123456789012345678901234567890123456"
80       "789012345678901234567890123456789012345678901234567890123456789012345678"
81       "901234567890123456789012345678901234567890123456789012345678901234567890"
82       "123456789012345678901234567890123456789012345678901234567890123456789012"
83       "345678901234567890123456789012345678901234567890123456789012345678901234"
84       "567890123456789012345678901234567890123456789012345678901234567890123456"
85       "789012345678901234567890123456789012345678901234567890123456789012345678"
86       "901234567890123456789012345678901234567890123456789012345678901234567890"
87       "1234567890123456789012345678901234567890");
88   std::string_view IHaveEmbeddedZeros("a\0b\0c\0d", 7);
89   std::wstring_view IHaveEmbeddedZerosToo(
90       L"hello world!\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監", 38);
91   std::u16string_view u16_string(u"ß水氶");
92   std::u16string_view u16_empty(u"");
93   std::u32string_view u32_string(U"��������");
94   std::u32string_view u32_empty(U"");
95   std::string_view *null_str = nullptr;
96 
97   std::string hello = "Hellooo ";
98   std::string_view oops = hello + "World\n";
99 
100   q_source[0] = 'H'; // Set break point at this line.
101 
102   std::string_view *not_a_string_view = nullptr;
103   touch_string(*not_a_string_view);
104 
105   return 0;
106 }
107