This is an automated email from the ASF dual-hosted git repository. ronny pushed a commit to branch update-snappy in repository https://gitbox.apache.org/repos/asf/couchdb-snappy.git
commit 990f6884a61474e30a1da59da664a8023c3663d0 Author: Peter Membrey <[email protected]> AuthorDate: Fri May 16 22:20:47 2014 +0800 Added additional tests for multiple compress / decompress and checked compress and decompress separately. --- test/snappy_tests.erl | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/test/snappy_tests.erl b/test/snappy_tests.erl index 0b42398..f8b8550 100644 --- a/test/snappy_tests.erl +++ b/test/snappy_tests.erl @@ -72,9 +72,36 @@ decompression() -> ?assertEqual({ok, BigData}, snappy:decompress(Compressed3)), ok. +check_double_decompress_doesnt_cause_segault_test() -> + % Try to decompress an empty binary + ?assertMatch({ok,<<>>}, snappy:decompress(<<>>)), + % And once more... + ?assertMatch({ok,<<>>}, snappy:decompress(<<>>)), + ok. + +check_double_compress_doesnt_cause_segault_test() -> + % Try to compress an empty binary + ?assertMatch({ok,<<>>},snappy:compress(<<>>)), + % And once more... + ?assertMatch({ok,<<>>},snappy:compress(<<>>)), + ok. + can_compress_and_decompress_empty_binary_test() -> - % Try to compress an empty list... + % Try to compress an empty binary... {ok, Compressed} = snappy:compress(<<>>), % Try to decompress the result of the compression... {ok, Decompressed} = snappy:decompress(Compressed), ok. + +can_compress_an_empty_binary_test() -> + % Try to compress an empty binary... + {ok, Compressed} = snappy:compress(<<>>), + % Check an empty binary was returned + ?assertMatch(Compressed,<<>>), + ok. + +can_decompress_an_empty_binary_test() -> + % Try to decompress an empty binary + {ok, Decompressed} = snappy:decompress(<<>>), + ?assertMatch(Decompressed,<<>>), + ok.
