MCPcopy Create free account
hub / github.com/ElementsProject/elements / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/test/streams_tests.cpp:15–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13BOOST_FIXTURE_TEST_SUITE(streams_tests, BasicTestingSetup)
14
15BOOST_AUTO_TEST_CASE(streams_vector_writer)
16{
17 unsigned char a(1);
18 unsigned char b(2);
19 unsigned char bytes[] = { 3, 4, 5, 6 };
20 std::vector<unsigned char> vch;
21
22 // Each test runs twice. Serializing a second time at the same starting
23 // point should yield the same results, even if the first test grew the
24 // vector.
25
26 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, a, b);
27 BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
28 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, a, b);
29 BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
30 vch.clear();
31
32 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b);
33 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
34 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b);
35 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
36 vch.clear();
37
38 vch.resize(5, 0);
39 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b);
40 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
41 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b);
42 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
43 vch.clear();
44
45 vch.resize(4, 0);
46 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 3, a, b);
47 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
48 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 3, a, b);
49 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
50 vch.clear();
51
52 vch.resize(4, 0);
53 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 4, a, b);
54 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
55 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 4, a, b);
56 BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
57 vch.clear();
58
59 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, bytes);
60 BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
61 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, bytes);
62 BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
63 vch.clear();
64
65 vch.resize(4, 8);
66 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, bytes, b);
67 BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
68 CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, bytes, b);
69 BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
70 vch.clear();
71}
72

Callers

nothing calls this directly

Calls 15

CVectorWriterClass · 0.85
fopenFunction · 0.85
SeedInsecureRandFunction · 0.85
InsecureRandRangeFunction · 0.85
XorMethod · 0.80
strMethod · 0.80
GetPosMethod · 0.80
SetPosMethod · 0.80
SetLimitMethod · 0.80
FindByteMethod · 0.80
clearMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected