MCPcopy Create free account
hub / github.com/boostorg/beast / testConstruct

Method testConstruct

test/beast/core/static_string.cpp:21–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19{
20public:
21 void
22 testConstruct()
23 {
24 {
25 static_string<1> s;
26 BEAST_EXPECT(s.empty());
27 BEAST_EXPECT(s.size() == 0);
28 BEAST_EXPECT(s == "");
29 BEAST_EXPECT(*s.end() == 0);
30 }
31 {
32 static_string<4> s1(3, 'x');
33 BEAST_EXPECT(! s1.empty());
34 BEAST_EXPECT(s1.size() == 3);
35 BEAST_EXPECT(s1 == "xxx");
36 BEAST_EXPECT(*s1.end() == 0);
37 try
38 {
39 static_string<2> s2(3, 'x');
40 fail("", __FILE__, __LINE__);
41 }
42 catch(std::length_error const&)
43 {
44 pass();
45 }
46 }
47 {
48 static_string<5> s1("12345");
49 BEAST_EXPECT(*s1.end() == 0);
50 static_string<3> s2(s1, 2);
51 BEAST_EXPECT(s2 == "345");
52 BEAST_EXPECT(*s2.end() == 0);
53 static_string<0> s3(s1, 5);
54 BEAST_EXPECT(s3.empty());
55 BEAST_EXPECT(s3.front() == 0);
56 BEAST_EXPECT(*s3.end() == 0);
57 }
58 {
59 static_string<5> s1("12345");
60 static_string<2> s2(s1, 1, 2);
61 BEAST_EXPECT(s2 == "23");
62 BEAST_EXPECT(*s2.end() == 0);
63 static_string<0> s3(s1, 5, 1);
64 BEAST_EXPECT(s3.empty());
65 BEAST_EXPECT(s3.front() == 0);
66 BEAST_EXPECT(*s3.end() == 0);
67 try
68 {
69 static_string<5> s4(s1, 6);
70 fail("", __FILE__, __LINE__);
71 }
72 catch(std::out_of_range const&)
73 {
74 pass();
75 }
76 }
77 {
78 static_string<5> s1("UVXYZ", 3);

Callers

nothing calls this directly

Calls 6

failFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected