test/src/scale/scale_collection_test.cpp
TEST(Scale, DISABLED_encodeVeryLongCollectionUint8) {
  auto length = 1073741824;  // 2^20
  std::vector<uint8_t> collection;

  collection.reserve(length);
  for (auto i = 0; i < length; ++i) {
    collection.push_back(i % 256);
  }

  ScaleEncoderStream s;
  ASSERT_NO_THROW((s << collection));
  auto &&out = s.data();
  ASSERT_EQ(out.size(), (length + 4));
  // header takes 4 bytes,
  // first byte == (4-4) + 3 = 3, which means that number of items
  // requires 4 bytes
  // 3 next bytes are 0, and the last 4-th == 2^6 == 64
  // which is compact-encoded value 2^14 = 16384
  auto stream = ScaleDecoderStream(gsl::make_span(out));
  CompactInteger bi{};
  ASSERT_NO_THROW(stream >> bi);
  ASSERT_EQ(bi, length);

  // now only 1048576 bytes left in stream
  ASSERT_EQ(stream.hasMore(length), true);
  ASSERT_EQ(stream.hasMore(length + 1), false);

  for (auto i = 0; i < length; ++i) {
    uint8_t byte = 0u;
    ASSERT_NO_THROW(stream >> byte);
    ASSERT_EQ(byte, i % 256);
  }

  ASSERT_EQ(stream.hasMore(1), false);
}
// following test takes too much time, don't run it
/**
 * @given very long collection of items of type uint8_t containing 2^30 ==
 * 1073741824 items this number takes ~ 1 Gb of data where collection[i]  == i %
 * 256
 * @when encodeCollection is applied
 * @then obtain byte array of length 1073741824 + 5 bytes (header) bytes
 * where first bytes represent header, other are data itself
 * where each byte after header == i%256
 */
following test takes too much time, don't run it
@given very long collection of items of type uint8_t containing 2^30
1073741824 items this number takes ~ 1 Gb of data where collection[i]  == i %
256
@when encodeCollection is applied
@then obtain byte array of length 1073741824 + 5 bytes (header) bytes
where first bytes represent header, other are data itself
where each byte after header == i%256
following test takes too much time don ' t run it @given very long collection of items of type uint8_t containing 2^30 1073741824 items this number takes ~ 1 Gb of data where collection [ i ] == i % 256 @when encodeCollection is applied @then obtain byte array of length 1073741824 + 5 bytes ( header ) bytes where first bytes represent header other are data itself where each byte after header == i%256
TEST(Scale, DISABLED_encodeVeryLongCollectionUint8) {
  auto length = 1073741824;  
  std::vector<uint8_t> collection;
  collection.reserve(length);
  for (auto i = 0; i < length; ++i) {
    collection.push_back(i % 256);
  }
  ScaleEncoderStream s;
  ASSERT_NO_THROW((s << collection));
  auto &&out = s.data();
  ASSERT_EQ(out.size(), (length + 4));
  auto stream = ScaleDecoderStream(gsl::make_span(out));
  CompactInteger bi{};
  ASSERT_NO_THROW(stream >> bi);
  ASSERT_EQ(bi, length);
  ASSERT_EQ(stream.hasMore(length), true);
  ASSERT_EQ(stream.hasMore(length + 1), false);
  for (auto i = 0; i < length; ++i) {
    uint8_t byte = 0u;
    ASSERT_NO_THROW(stream >> byte);
    ASSERT_EQ(byte, i % 256);
  }
  ASSERT_EQ(stream.hasMore(1), false);
}
TEST ( Scale , DISABLED_encodeVeryLongCollectionUint8 ) { auto length = 1073741824 ; std :: vector < uint8_t > collection ; collection . reserve ( length ) ; for ( auto i = 0 ; i < length ; ++ i ) { collection . push_back ( i % 256 ) ; } ScaleEncoderStream s ; ASSERT_NO_THROW ( ( s << collection ) ) ; auto && out = s . data ( ) ; ASSERT_EQ ( out . size ( ) , ( length + 4 ) ) ; auto stream = ScaleDecoderStream ( gsl :: make_span ( out ) ) ; CompactInteger bi { } ; ASSERT_NO_THROW ( stream >> bi ) ; ASSERT_EQ ( bi , length ) ; ASSERT_EQ ( stream . hasMore ( length ) , true ) ; ASSERT_EQ ( stream . hasMore ( length + 1 ) , false ) ; for ( auto i = 0 ; i < length ; ++ i ) { uint8_t byte = 0u ; ASSERT_NO_THROW ( stream >> byte ) ; ASSERT_EQ ( byte , i % 256 ) ; } ASSERT_EQ ( stream . hasMore ( 1 ) , false ) ; }
following test takes too much time, don't run it
 @given very long collection of items of type uint8_t containing 2^30
 1073741824 items this number takes ~ 1 Gb of data where collection[i]  == i %
 256
 @when encodeCollection is applied
 @then obtain byte array of length 1073741824 + 5 bytes (header) bytes
 where first bytes represent header, other are data itself
 where each byte after header == i%256
following test takes too much time don ' t run it @given very long collection of items of type uint8_t containing 2^30 1073741824 items this number takes ~ 1 Gb of data where collection [ i ] == i % 256 @when encodeCollection is applied @then obtain byte array of length 1073741824 + 5 bytes ( header ) bytes where first bytes represent header other are data itself where each byte after header == i%256
// 2^20 // header takes 4 bytes, // first byte == (4-4) + 3 = 3, which means that number of items // requires 4 bytes // 3 next bytes are 0, and the last 4-th == 2^6 == 64 // which is compact-encoded value 2^14 = 16384 // now only 1048576 bytes left in stream