#include <boost/test/included/unit_test.hpp>
#include <fc/variant_object.hpp>
#include <fc/exception/exception.hpp>
#include <fc/crypto/base64.hpp>
#include <string>
Go to the source code of this file.
◆ BOOST_TEST_MODULE
◆ BOOST_AUTO_TEST_CASE() [1/8]
BOOST_AUTO_TEST_CASE |
( |
array_variant_estimated_size_test | | ) |
|
Definition at line 138 of file test_variant_estimated_size.cpp.
139{
140 bool b = true;
141 wchar_t wc[] = L"Goodbye";
143
147
149 vs.push_back(v_bool);
150 vs.push_back(v_wchar);
151 vs.push_back(v_uint32);
152
154 BOOST_CHECK_EQUAL(v_variants.estimated_size(), 7 +
sizeof(
string) + 4 *
sizeof(
variant) +
sizeof(
variants));
155}
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
std::vector< fc::variant > variants
◆ BOOST_AUTO_TEST_CASE() [2/8]
BOOST_AUTO_TEST_CASE |
( |
blob_variant_estimated_size_test | | ) |
|
Definition at line 92 of file test_variant_estimated_size.cpp.
93{
95 bl.data.push_back(
'f');
96 bl.data.push_back(
'o');
97 bl.data.push_back(
'o');
98
100
101 BOOST_CHECK_EQUAL(v_blob.estimated_size(), 3 +
sizeof(
variant) +
sizeof(
blob));
102}
static const Reg8 bl(Operand::BL)
◆ BOOST_AUTO_TEST_CASE() [3/8]
BOOST_AUTO_TEST_CASE |
( |
double_variant_estimated_size_test | | ) |
|
◆ BOOST_AUTO_TEST_CASE() [4/8]
BOOST_AUTO_TEST_CASE |
( |
int64_variant_estimated_size_test | | ) |
|
Definition at line 23 of file test_variant_estimated_size.cpp.
24{
29
34
35 BOOST_CHECK_EQUAL(v_int_64.estimated_size(),
sizeof(
variant));
36 BOOST_CHECK_EQUAL(v_int_32.estimated_size(),
sizeof(
variant));
37 BOOST_CHECK_EQUAL(v_int_16.estimated_size(),
sizeof(
variant));
38 BOOST_CHECK_EQUAL(v_int_8.estimated_size(),
sizeof(
variant));
39}
◆ BOOST_AUTO_TEST_CASE() [5/8]
BOOST_AUTO_TEST_CASE |
( |
null_variant_estimated_size_test | | ) |
|
Definition at line 12 of file test_variant_estimated_size.cpp.
13{
15
18
20 BOOST_CHECK_EQUAL(v_nullptr.estimated_size(),
sizeof(
variant));
21}
size_t estimated_size() const
decltype(nullptr) nullptr_t
◆ BOOST_AUTO_TEST_CASE() [6/8]
BOOST_AUTO_TEST_CASE |
( |
string_variant_estimated_size_test | | ) |
|
Definition at line 71 of file test_variant_estimated_size.cpp.
72{
73 char c[] = "Hello World";
74 const char* cc = "Goodbye";
75 wchar_t wc[] = L"0123456789";
76 const wchar_t* cwc = L"foo";
77 string s =
"abcdefghijklmnopqrstuvwxyz";
78
84
85 BOOST_CHECK_EQUAL(v_char.estimated_size(), 11 +
sizeof(
variant) +
sizeof(
string));
86 BOOST_CHECK_EQUAL(v_const_char.estimated_size(), 7 +
sizeof(
variant) +
sizeof(
string));
87 BOOST_CHECK_EQUAL(v_wchar.estimated_size(), 10 +
sizeof(
variant) +
sizeof(
string));
88 BOOST_CHECK_EQUAL(v_const_wchar.estimated_size(), 3 +
sizeof(
variant) +
sizeof(
string));
89 BOOST_CHECK_EQUAL(v_string.estimated_size(), 26 +
sizeof(
variant) +
sizeof(
string));
90}
◆ BOOST_AUTO_TEST_CASE() [7/8]
BOOST_AUTO_TEST_CASE |
( |
uint64_variant_estimated_size_test | | ) |
|
Definition at line 41 of file test_variant_estimated_size.cpp.
42{
47
52
53 BOOST_CHECK_EQUAL(v_uint_64.estimated_size(),
sizeof(
variant));
54 BOOST_CHECK_EQUAL(v_uint_32.estimated_size(),
sizeof(
variant));
55 BOOST_CHECK_EQUAL(v_uint_16.estimated_size(),
sizeof(
variant));
56 BOOST_CHECK_EQUAL(v_uint_8.estimated_size(),
sizeof(
variant));
57}
unsigned __int64 uint64_t
◆ BOOST_AUTO_TEST_CASE() [8/8]
BOOST_AUTO_TEST_CASE |
( |
variant_object_variant_estimated_size_test | | ) |
|
Definition at line 104 of file test_variant_estimated_size.cpp.
105{
106 string k1 =
"key_bool";
107 string k2 =
"key_string";
108 string k3 =
"key_int16";
109 string k4 =
"key_blob";
110
111 bool b = false;
112 string s =
"HelloWorld";
115 bl.data.push_back(
'b');
116 bl.data.push_back(
'a');
117 bl.data.push_back(
'r');
118
123
125 mu(k1, b);
126 mu(k2, v_string);
127 mu(k3, v_int16);
128 mu(k4, bl);
131
132 BOOST_CHECK_EQUAL(vo.estimated_size(), 48 + 5 *
sizeof(
string) +
sizeof(
blob) + 4 *
sizeof(
variant) +
133 sizeof(
variant_object) +
sizeof(std::vector<variant_object::entry>));
134 BOOST_CHECK_EQUAL(v_vo.estimated_size(), 48 + 5 *
sizeof(
string) +
sizeof(
blob) + 5 *
sizeof(
variant) +
135 sizeof(
variant_object) +
sizeof(std::vector<variant_object::entry>));
136}
An order-preserving dictionary of variants.
An order-preserving dictionary of variants.
static const Opmask k3(3)
static const Opmask k4(4)
static const Opmask k2(2)
static const Opmask k1(1)