@@ -239,25 +239,26 @@ void TestStatistics<ByteArrayType>::AddNodes(std::string name) {
239239
240240template <>
241241void TestStatistics<ByteArrayType>::SetValues() {
242- int max_byte_array_len = 4 ;
242+ int max_byte_array_len = 10 ;
243243 size_t nbytes = NUM_VALUES * max_byte_array_len;
244244 values_buf_.resize (nbytes);
245245 std::vector<std::string> vals = {u8" c123" , u8" b123" , u8" a123" , u8" d123" , u8" e123" ,
246246 u8" f123" , u8" g123" , u8" h123" , u8" i123" , u8" ü123" };
247247
248+ uint8_t * base = &values_buf_.data ()[0 ];
248249 for (int i = 0 ; i < NUM_VALUES; i++) {
249- uint8_t * base = &values_buf_.data ()[0 ] + (i * max_byte_array_len);
250- memcpy (base, vals[i].c_str (), max_byte_array_len);
250+ memcpy (base, vals[i].c_str (), vals[i].length ());
251251 values_[i].ptr = base;
252- values_[i].len = max_byte_array_len;
252+ values_[i].len = static_cast <uint32_t >(vals[i].length ());
253+ base += vals[i].length ();
253254 }
254255
255256 // Write String min/max values
256257 stats_[0 ]
257258 .set_min (
258- std::string (reinterpret_cast <const char *>(vals[2 ].c_str ()), max_byte_array_len ))
259+ std::string (reinterpret_cast <const char *>(vals[2 ].c_str ()), vals[ 2 ]. length () ))
259260 .set_max (std::string (reinterpret_cast <const char *>(vals[9 ].c_str ()),
260- max_byte_array_len ));
261+ vals[ 9 ]. length () ));
261262}
262263
263264// TYPE::FLBAArray
@@ -273,22 +274,23 @@ template <>
273274void TestStatistics<FLBAType>::SetValues() {
274275 size_t nbytes = NUM_VALUES * FLBA_LENGTH;
275276 values_buf_.resize (nbytes);
276- std::vector<std::string> vals = {u8 " b12345" , u8" aü123456789 " , u8" c123 " , u8" d123 " ,
277- u8" e123 " , u8" f123 " , u8" g123 " , u8" h123 " ,
278- u8" üa123 " , u8" üa123456789 " };
277+ char vals[NUM_VALUES][FLBA_LENGTH] = {" b12345" , " a12345 " , " c12345 " , " d12345 " ,
278+ " e12345 " , " f12345 " , " g12345 " , " h12345 " ,
279+ " z12345 " , " a12345 " };
279280
281+ uint8_t * base = &values_buf_.data ()[0 ];
280282 for (int i = 0 ; i < NUM_VALUES; i++) {
281- uint8_t * base = &values_buf_.data ()[0 ] + (i * FLBA_LENGTH);
282- memcpy (base, vals[i].c_str (), vals[i].length ());
283+ memcpy (base, &vals[i][0 ], FLBA_LENGTH);
283284 values_[i].ptr = base;
285+ base += FLBA_LENGTH;
284286 }
285287
286288 // Write FLBA min,max values
287289 stats_[0 ]
288290 .set_min (
289- std::string (reinterpret_cast <const char *>(vals[1 ]. c_str ()), vals[ 1 ]. length () ))
291+ std::string (reinterpret_cast <const char *>(& vals[1 ][ 0 ]), FLBA_LENGTH ))
290292 .set_max (
291- std::string (reinterpret_cast <const char *>(vals[9 ]. c_str ()), vals[ 9 ]. length () ));
293+ std::string (reinterpret_cast <const char *>(& vals[8 ][ 0 ]), FLBA_LENGTH ));
292294}
293295
294296TYPED_TEST_CASE (TestStatistics, TestTypes);
0 commit comments