File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,29 @@ TEST(KaitaiStreamTest, process_zlib_ok)
225
225
EXPECT_EQ (kaitai::kstream::process_zlib (ks.read_bytes_full ()), " Hi" );
226
226
}
227
227
228
+ // It's probably not a good idea to run this test in CI because it has to allocate 4 GiB of memory.
229
+ // That's why it is disabled (see
230
+ // https://google.github.io/googletest/advanced.html#temporarily-disabling-tests). You can still run
231
+ // it locally using `.build/run-unittest --valgrind -- --gtest_also_run_disabled_tests` or
232
+ // `.build\run-unittest.ps1 --gtest_also_run_disabled_tests`.
233
+ TEST (KaitaiStreamTest, DISABLED_process_zlib_input_too_long)
234
+ {
235
+ try {
236
+ kaitai::kstream::process_zlib (
237
+ std::string (
238
+ static_cast <std::string::size_type>(std::numeric_limits<unsigned >::max ()) + 1 ,
239
+ ' \x00 '
240
+ )
241
+ );
242
+ FAIL () << " Expected runtime_error exception" ;
243
+ } catch (const std::length_error& e) {
244
+ EXPECT_EQ (e.what (), std::string (
245
+ " process_zlib: input is 4294967296 bytes long, which exceeds"
246
+ " the maximum supported length of 4294967295 bytes"
247
+ ));
248
+ }
249
+ }
250
+
228
251
// Tests a failed zlib decompression due to the `inflate()` function returning `Z_BUF_ERROR`.
229
252
TEST (KaitaiStreamTest, process_zlib_z_buf_error)
230
253
{
You can’t perform that action at this time.
0 commit comments