summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/transactionlog/chunks_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib/src/tests/transactionlog/chunks_test.cpp')
-rw-r--r--searchlib/src/tests/transactionlog/chunks_test.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/searchlib/src/tests/transactionlog/chunks_test.cpp b/searchlib/src/tests/transactionlog/chunks_test.cpp
index 8d6620c9f8b..ca03a47634d 100644
--- a/searchlib/src/tests/transactionlog/chunks_test.cpp
+++ b/searchlib/src/tests/transactionlog/chunks_test.cpp
@@ -115,4 +115,25 @@ TEST("test multi element commitchunk") {
}
EXPECT_EQUAL(0u, counter);
}
+
+TEST("shrinkToFit if difference is larger than 8x") {
+ Packet p(16000);
+ p.add(Packet::Entry(1, 3, ConstBufferRef(TEXT, strlen(TEXT))));
+ EXPECT_EQUAL(150u, p.sizeBytes());
+ EXPECT_EQUAL(16384u, p.getHandle().capacity());
+ p.shrinkToFit();
+ EXPECT_EQUAL(150u, p.sizeBytes());
+ EXPECT_EQUAL(150u, p.getHandle().capacity());
+}
+
+TEST("not shrinkToFit if difference is less than 8x") {
+ Packet p(1000);
+ p.add(Packet::Entry(1, 3, ConstBufferRef(TEXT, strlen(TEXT))));
+ EXPECT_EQUAL(150u, p.sizeBytes());
+ EXPECT_EQUAL(1024u, p.getHandle().capacity());
+ p.shrinkToFit();
+ EXPECT_EQUAL(150u, p.sizeBytes());
+ EXPECT_EQUAL(1024u, p.getHandle().capacity());
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }