MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / TEST

Function TEST

source/MRTest/MRZlibTests.cpp:136–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134) );
135
136TEST( MRMesh, ZlibCompressStats )
137{
138 const std::string inputStr( reinterpret_cast<const char*>( cInput ), sizeof( cInput ) );
139 const uint32_t expectedCrc = crc32Ref( cInput, sizeof( cInput ) );
140
141 struct Case { bool rawDeflate; int level; };
142 const Case cases[] = {
143 { true, 1 },
144 { true, 9 },
145 { false, 1 },
146 { false, 9 },
147 };
148
149 for ( const auto& c : cases )
150 {
151 MR::ZlibCompressStats stats;
152 std::istringstream in( inputStr );
153 std::ostringstream out;
154 auto res = MR::zlibCompressStream( in, out,
155 MR::ZlibCompressParams{ { .rawDeflate = c.rawDeflate }, c.level, &stats } );
156 EXPECT_TRUE( res.has_value() );
157
158 // Engine-agnostic assertions: CRC and uncompressed size are defined by
159 // the input; stats.compressedSize must equal out.str().size() (API
160 // consistency); compressed output must be non-empty and smaller than
161 // the input. We deliberately do NOT pin stats.compressedSize to the
162 // size of cRawLevel*/cWrappedLevel* -- those reference blobs were
163 // captured from stock zlib, and the exact compressed byte count drifts
164 // from one deflate implementation to another (stock zlib vs zlib-ng
165 // compat vs zlib-ng native vs libdeflate, all lossless).
166 EXPECT_EQ( stats.crc32, expectedCrc );
167 EXPECT_EQ( stats.uncompressedSize, sizeof( cInput ) );
168 EXPECT_EQ( stats.compressedSize, out.str().size() );
169 EXPECT_GT( stats.compressedSize, 0u );
170 EXPECT_LT( stats.compressedSize, sizeof( cInput ) );
171 }
172}
173
174TEST( MRMesh, ZlibCompressStatsEmpty )
175{

Callers

nothing calls this directly

Calls 3

crc32RefFunction · 0.85
zlibCompressStreamFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected