]> git.lyx.org Git - features.git/blob - src/support/tests/check_trivstring.cpp
e6a23d560320b05f1c70af9f90f0a0c0e0c5c7a6
[features.git] / src / support / tests / check_trivstring.cpp
1 #include <config.h>
2
3 #include "../trivstring.h"
4
5 #include <iostream>
6
7
8 using namespace lyx;
9
10 using namespace std;
11
12 void test_trivstring()
13 {
14         string const input[] = {
15                 "",
16                 "a",
17                 "42",
18                 "max sso", // max. string with sso on 64 bit
19                 "something which does not fit into sso"
20         };
21         size_t const n = sizeof(input) / sizeof(input[0]);
22         for (size_t i = 0; i < n; ++i) {
23                 // construction from std::string
24                 trivstring const a(input[i]);
25                 // construction from trivstring
26                 trivstring const b(a);
27                 // assignment from trivstring
28                 trivstring const c = a;
29                 // assignment from std::string
30                 trivstring const d = input[i];
31                 // assignment from trivstring
32                 string const e = a.str();
33                 // assignment from trivstring via C string
34                 string const f = a.c_str();
35                 cout << a.length() << endl;
36                 cout << a.str() << endl;
37                 cout << b.str() << endl;
38                 cout << c.str() << endl;
39                 cout << d.str() << endl;
40                 cout << e << endl;
41                 cout << f << endl;
42         }
43 }
44
45 int main()
46 {
47         test_trivstring();
48 }