summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/docstore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-09-21 12:37:36 +0200
committerHenning Baldersheim <balder@oath.com>2018-09-21 12:37:36 +0200
commitd27c24d43b83a216d6f7096dae4b49a0577eccf1 (patch)
tree2527da2116aff6df62066eb583fbe4b590c01063 /searchlib/src/tests/docstore
parentc1c5842611dbb3643f374946a8d6107246c13f5b (diff)
Add test for compressed content
Diffstat (limited to 'searchlib/src/tests/docstore')
-rw-r--r--searchlib/src/tests/docstore/document_store/document_store_test.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/searchlib/src/tests/docstore/document_store/document_store_test.cpp b/searchlib/src/tests/docstore/document_store/document_store_test.cpp
index fc2d2ab0536..a36f2585f28 100644
--- a/searchlib/src/tests/docstore/document_store/document_store_test.cpp
+++ b/searchlib/src/tests/docstore/document_store/document_store_test.cpp
@@ -84,7 +84,8 @@ TEST("require that LogDocumentStore::Config equality operator detects inequality
using search::docstore::Value;
vespalib::stringref S1("this is a string long enough to be compressed and is just used for sanity checking of compression"
- "Adding some repeatble sequences like aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbb to ensure compression");
+ "Adding some repeatble sequences like aaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbb to ensure compression"
+ "xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz");
Value createValue(vespalib::stringref s, const CompressionConfig & cfg) {
Value v(7);
@@ -99,6 +100,7 @@ void verifyValue(vespalib::stringref s, const Value & v) {
EXPECT_EQUAL(7u, v.getSyncToken());
EXPECT_EQUAL(0, memcmp(s.data(), buf.getData(), buf.getDataLen()));
}
+
TEST("require that Value can store uncompressed data") {
Value v = createValue(S1, CompressionConfig::NONE);
verifyValue(S1, v);
@@ -117,4 +119,18 @@ TEST("require that Value can be copied") {
verifyValue(S1, copy);
}
+TEST("require that Value can store lz4 compressed data") {
+ Value v = createValue(S1, CompressionConfig::LZ4);
+ EXPECT_EQUAL(CompressionConfig::LZ4, v.getCompression());
+ EXPECT_EQUAL(164u, v.size());
+ verifyValue(S1, v);
+}
+
+TEST("require that Value can store zstd compressed data") {
+ Value v = createValue(S1, CompressionConfig::ZSTD);
+ EXPECT_EQUAL(CompressionConfig::ZSTD, v.getCompression());
+ EXPECT_EQUAL(128u, v.size());
+ verifyValue(S1, v);
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }