aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2017-11-25 17:18:21 +0100
committerMarcus Brinkmann <[email protected]>2017-11-25 17:19:38 +0100
commit3f8c4add59f4db347f8594a49c846c85ce1e296d (patch)
treeb9b3ce864e962f2e607c8afc192d14f47edbab08 /src
parentc23eb5eb3463459654e0f6601a3b2304eb2076ee (diff)
Add test case for bzip2 compression filter.
Diffstat (limited to 'src')
-rw-r--r--src/tests/test_filters.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/tests/test_filters.cpp b/src/tests/test_filters.cpp
index b8a4ee9f0..84e74e12d 100644
--- a/src/tests/test_filters.cpp
+++ b/src/tests/test_filters.cpp
@@ -57,6 +57,7 @@ class Filter_Tests final : public Test
results.push_back(test_pipe_cbc());
results.push_back(test_pipe_cfb());
results.push_back(test_pipe_compress());
+ results.push_back(test_pipe_compress_bzip2());
results.push_back(test_pipe_codec());
results.push_back(test_fork());
results.push_back(test_chain());
@@ -495,6 +496,41 @@ class Filter_Tests final : public Test
return result;
}
+ Test::Result test_pipe_compress_bzip2()
+ {
+ Test::Result result("Pipe");
+
+#if defined(BOTAN_HAS_BZIP2)
+
+ std::unique_ptr<Botan::Compression_Filter> comp_f(new Botan::Compression_Filter("bzip2", 9));
+
+ result.test_eq("Compressor filter name", comp_f->name(), "Bzip2_Compression");
+ Botan::Pipe pipe(comp_f.release());
+
+ const std::string input_str = "foo\n";
+
+ pipe.start_msg();
+ pipe.write(input_str);
+ pipe.end_msg();
+
+ auto compr = pipe.read_all(0);
+ // Can't do equality check on compression because output may differ
+ result.test_lt("Compressed is shorter", compr.size(), input_str.size());
+
+ std::unique_ptr<Botan::Decompression_Filter> decomp_f(new Botan::Decompression_Filter("bzip2"));
+ result.test_eq("Decompressor name", decomp_f->name(), "Bzip2_Decompression");
+ pipe.append(decomp_f.release());
+ pipe.pop(); // remove compressor
+
+ pipe.process_msg(compr);
+
+ std::string decomp = pipe.read_all_as_string(1);
+ result.test_eq("Decompressed ok", decomp, input_str);
+#endif
+
+ return result;
+ }
+
Test::Result test_pipe_codec()
{
Test::Result result("Pipe");