diff options
author | Daniel Seither <[email protected]> | 2015-08-28 15:50:58 +0200 |
---|---|---|
committer | Daniel Seither <[email protected]> | 2015-08-28 15:50:58 +0200 |
commit | 47d9e96f1c6e10cef9b8d1803b6350bcf8696b49 (patch) | |
tree | 65ff9175f310491e46f3c1f983e614c81691147a /src | |
parent | 58329e7602e07468396ba29d6404c01ce5edec42 (diff) |
Add test for compression of an empty buffer
This test currently fails:
$ ./botan-test compression
Failure testing zlib - zlib deflate error -2
Failure testing deflate - zlib deflate error -2
Failure testing gzip - zlib deflate error -2
Compression 3 tests 3 FAILs
===============
Tests 3 FAILs
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/test_compression.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tests/test_compression.cpp b/src/tests/test_compression.cpp index b68262385..902455fc7 100644 --- a/src/tests/test_compression.cpp +++ b/src/tests/test_compression.cpp @@ -93,12 +93,15 @@ size_t test_compression() const size_t text_len = strlen(text_str); + const secure_vector<byte> empty; const secure_vector<byte> all_zeros(text_len, 0); const secure_vector<byte> random_binary = test_rng().random_vec(text_len); const byte* textb = reinterpret_cast<const byte*>(text_str); const secure_vector<byte> text(textb, textb + text_len); + const size_t c1_e = run_compression(*c1, *d, empty); + const size_t c9_e = run_compression(*c9, *d, empty); const size_t c1_z = run_compression(*c1, *d, all_zeros); const size_t c9_z = run_compression(*c9, *d, all_zeros); const size_t c1_r = run_compression(*c1, *d, random_binary); @@ -108,6 +111,10 @@ size_t test_compression() #define BOTAN_TEST_GTE(x, y, msg) if(x < y) { ++fails; std::cout << "FAIL: " << x << " " << y << " " << msg << std::endl; } + BOTAN_TEST_GTE(c1_e, 1, "Empty input compresses to non-empty output"); + BOTAN_TEST_GTE(c9_e, 1, "Empty input compresses to non-empty output"); + + BOTAN_TEST_GTE(c1_e, c9_e, "Level 9 compresses at least as well as level 1"); BOTAN_TEST_GTE(c1_z, c9_z, "Level 9 compresses at least as well as level 1"); BOTAN_TEST_GTE(c1_t, c9_t, "Level 9 compresses at least as well as level 1"); BOTAN_TEST_GTE(c1_r, c9_r, "Level 9 compresses at least as well as level 1"); |