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

Method testSpecialMembers

test/beast/core/flat_buffer.cpp:40–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38 }
39
40 void
41 testSpecialMembers()
42 {
43 using namespace test;
44
45 using a_t = test::test_allocator<char,
46 true, true, true, true, true>;
47
48 // Equal == false
49 using a_neq_t = test::test_allocator<char,
50 false, true, true, true, true>;
51
52 // construction
53 {
54 {
55 flat_buffer b;
56 BEAST_EXPECT(b.capacity() == 0);
57 }
58 {
59 flat_buffer b{500};
60 BEAST_EXPECT(b.capacity() == 0);
61 BEAST_EXPECT(b.max_size() == 500);
62 }
63 {
64 a_neq_t a1;
65 basic_flat_buffer<a_neq_t> b{a1};
66 BEAST_EXPECT(b.get_allocator() == a1);
67 a_neq_t a2;
68 BEAST_EXPECT(b.get_allocator() != a2);
69 }
70 {
71 a_neq_t a;
72 basic_flat_buffer<a_neq_t> b{500, a};
73 BEAST_EXPECT(b.capacity() == 0);
74 BEAST_EXPECT(b.max_size() == 500);
75 }
76 }
77
78 // move construction
79 {
80 {
81 basic_flat_buffer<a_t> b1{30};
82 BEAST_EXPECT(b1.get_allocator()->nmove == 0);
83 ostream(b1) << "Hello";
84 basic_flat_buffer<a_t> b2{std::move(b1)};
85 BEAST_EXPECT(b2.get_allocator()->nmove == 1);
86 BEAST_EXPECT(b1.size() == 0);
87 BEAST_EXPECT(b1.capacity() == 0);
88 BEAST_EXPECT(buffers_to_string(b2.data()) == "Hello");
89 BEAST_EXPECT(b1.max_size() == b2.max_size());
90 }
91 {
92 basic_flat_buffer<a_t> b1{30};
93 ostream(b1) << "Hello";
94 a_t a;
95 basic_flat_buffer<a_t> b2{std::move(b1), a};
96 BEAST_EXPECT(b1.size() == 0);
97 BEAST_EXPECT(b1.capacity() == 0);

Callers

nothing calls this directly

Calls 14

moveClass · 0.85
buffers_to_stringFunction · 0.85
read_sizeFunction · 0.85
failFunction · 0.50
swapFunction · 0.50
capacityMethod · 0.45
max_sizeMethod · 0.45
get_allocatorMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
consumeMethod · 0.45
prepareMethod · 0.45

Tested by

no test coverage detected