diff options
author | Henning Baldersheim <balder@oath.com> | 2018-09-21 12:08:28 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-09-21 12:09:03 +0200 |
commit | c1c5842611dbb3643f374946a8d6107246c13f5b (patch) | |
tree | 7d7ed795483ac6c4efb2d5e3ee4efd92493ae8f9 /searchlib/src/tests | |
parent | 0fbc4d579dd3a05a42dc224f7e883d56051052f4 (diff) |
Refactor for testability.
Diffstat (limited to 'searchlib/src/tests')
-rw-r--r-- | searchlib/src/tests/docstore/document_store/document_store_test.cpp | 36 |
1 files changed, 36 insertions, 0 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 0ef04d0e722..fc2d2ab0536 100644 --- a/searchlib/src/tests/docstore/document_store/document_store_test.cpp +++ b/searchlib/src/tests/docstore/document_store/document_store_test.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/docstore/logdocumentstore.h> +#include <vespa/searchlib/docstore/value.h> #include <vespa/searchlib/docstore/cachestats.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/fieldvalue/document.h> @@ -81,4 +82,39 @@ TEST("require that LogDocumentStore::Config equality operator detects inequality EXPECT_FALSE(C(DC(), LC().setMaxBucketSpread(7)) == C()); } +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"); + +Value createValue(vespalib::stringref s, const CompressionConfig & cfg) { + Value v(7); + vespalib::DataBuffer input; + input.writeBytes(s.data(), s.size()); + v.set(std::move(input), s.size(), cfg); + return v; +} +void verifyValue(vespalib::stringref s, const Value & v) { + vespalib::DataBuffer buf = v.decompressed(); + EXPECT_EQUAL(s.size(), v.getUncompressedSize()); + 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); +} + +TEST("require that Value can be moved") { + Value v = createValue(S1, CompressionConfig::NONE); + Value m = std::move(v); + verifyValue(S1, m); +} + +TEST("require that Value can be copied") { + Value v = createValue(S1, CompressionConfig::NONE); + Value copy(v); + verifyValue(S1, v); + verifyValue(S1, copy); +} + TEST_MAIN() { TEST_RUN_ALL(); } |