aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/shared_string_repo
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2022-06-16 13:36:55 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2022-06-16 13:36:55 +0000
commit2890f01ab086c86d8167eaac8229cb44cb0fe2fa (patch)
tree69a0b9adfc3a2a684b5f62a33e2a185c60e317c7 /vespalib/src/tests/shared_string_repo
parent9990fd125ad30910bf1c2cf5c251d4262a903440 (diff)
enable making string handles directly from numbers
used in peek/slice to avoid having to convert small numbers to strings before resolving the enum values.
Diffstat (limited to 'vespalib/src/tests/shared_string_repo')
-rw-r--r--vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp b/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp
index acc710f8818..9edacf5e776 100644
--- a/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp
+++ b/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp
@@ -498,6 +498,24 @@ TEST("require that basic multi-handle usage works") {
//-----------------------------------------------------------------------------
+void verify_same_enum(int64_t num, const vespalib::string &str) {
+ Handle n = Handle::handle_from_number(num);
+ Handle s(str);
+ EXPECT_EQUAL(n.id().value(), s.id().value());
+}
+
+TEST("require that numeric label resolving works as expected") {
+ TEST_DO(verify_same_enum(-123, "-123"););
+ TEST_DO(verify_same_enum(-1, "-1"););
+ TEST_DO(verify_same_enum(0, "0"););
+ TEST_DO(verify_same_enum(123, "123"););
+ TEST_DO(verify_same_enum(9999999, "9999999"););
+ TEST_DO(verify_same_enum(10000000, "10000000"););
+ TEST_DO(verify_same_enum(999999999999, "999999999999"););
+}
+
+//-----------------------------------------------------------------------------
+
#if 0
// needs a lot of memory or tweaking of PART_LIMIT
TEST("allocate handles until we run out") {