@@ -94,51 +94,24 @@ void print_byteblob(TIter iter_begin, TIter iter_end) {
94
94
}
95
95
96
96
template <typename Endianness, class T , std::size_t TSize>
97
- void test_round_trip_non_fixed_size_container_fixed_precision (nil::marshalling::container::static_vector<T, TSize >
97
+ void test_round_trip_non_fixed_size_container_fixed_precision (std::vector<T >
98
98
val_container) {
99
99
using namespace nil ::crypto3::marshalling;
100
100
std::size_t units_bits = 8 ;
101
101
using unit_type = unsigned char ;
102
102
using integral_type = types::integral<nil::marshalling::field_type<Endianness>, T>;
103
103
104
- using container_type = nil::marshalling::types::array_list<
105
- nil::marshalling::field_type<Endianness>,
106
- integral_type,
107
- nil::marshalling::option::sequence_size_field_prefix<
108
- nil::marshalling::types::integral<nil::marshalling::field_type<Endianness>, std::size_t >>>;
104
+ nil::marshalling::status_type status;
105
+ std::vector<unit_type> cv =
106
+ nil::marshalling::unpack<Endianness, unit_type>(val_container, status);
109
107
110
- std::vector<T> val_vector (TSize);
111
- std::copy (val_container.begin (), val_container.end (), val_vector.begin ());
108
+ BOOST_CHECK (status == nil::marshalling::status_type::success);
112
109
113
- container_type filled_val = types::fill_integral_vector<T, Endianness>(val_vector );
110
+ std::vector<T> test_val = nil::marshalling::pack<Endianness, std::vector<T>>(cv, status );
114
111
115
- std::vector<T> constructed_val = types::make_integral_vector<T, Endianness>(filled_val);
116
- BOOST_CHECK (std::equal (val_container.begin (), val_container.end (), constructed_val.begin ()));
117
-
118
- std::size_t unitblob_size =
119
- integral_type::bit_length () / units_bits + ((integral_type::bit_length () % units_bits) ? 1 : 0 );
120
-
121
- std::vector<unit_type> cv;
122
- cv.resize (unitblob_size * TSize + sizeof (std::size_t ), 0x00 );
123
-
124
- std::vector<integral_type> container_data;
125
-
126
- for (std::size_t i = 0 ; i < TSize; i++) {
127
- container_data.push_back (integral_type (val_container[i]));
128
- }
129
-
130
- container_type test_val = container_type (container_data);
131
-
132
- auto write_iter = cv.begin ();
133
-
134
- nil::marshalling::status_type status = test_val.write (write_iter, cv.size ());
135
-
136
- container_type test_val_read;
137
-
138
- auto read_iter = cv.begin ();
139
- status = test_val_read.read (read_iter, cv.size ());
140
-
141
- BOOST_CHECK (std::equal (test_val.value ().begin (), test_val.value ().end (), test_val_read.value ().begin ()));
112
+ BOOST_CHECK (std::equal (val_container.begin (), val_container.end (), test_val.begin ()));
113
+ BOOST_CHECK (status == nil::marshalling::status_type::success);
114
+
142
115
}
143
116
144
117
template <typename Endianness, class T , std::size_t TSize>
@@ -149,7 +122,7 @@ void test_round_trip_non_fixed_size_container_fixed_precision() {
149
122
if (!(i % 128 ) && i) {
150
123
std::cout << std::dec << i << " tested" << std::endl;
151
124
}
152
- nil::marshalling::container::static_vector<T, TSize > val_container;
125
+ std::vector<T > val_container (TSize) ;
153
126
for (std::size_t i = 0 ; i < TSize; i++) {
154
127
val_container.push_back (generate_random<T>());
155
128
}
0 commit comments