summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp')
-rw-r--r--searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp b/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp
index 4a02ee7e943..d1bb5260b45 100644
--- a/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp
+++ b/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/searchlib/attribute/enumcomparator.h>
+#include <vespa/searchlib/attribute/dfa_string_comparator.h>
#include <vespa/vespalib/btree/btreeroot.h>
#include <vespa/vespalib/gtest/gtest.h>
@@ -23,6 +24,8 @@ using TreeType = BTreeRoot<AtomicEntryRef, BTreeNoLeafData,
const vespalib::datastore::EntryComparatorWrapper>;
using NodeAllocator = TreeType::NodeAllocatorType;
+using attribute::DfaStringComparator;
+
TEST(EnumComparatorTest, require_that_numeric_less_is_working)
{
@@ -192,6 +195,28 @@ TEST(EnumComparatorTest, require_that_folded_equal_is_working)
EXPECT_TRUE(cmp3.equal(EnumIndex(), EnumIndex())); // similar when prefix
}
+TEST(DfaStringComparatorTest, require_that_less_is_working)
+{
+ StringEnumStore es(false, DictionaryConfig::Type::BTREE);
+ EnumIndex e1 = es.insert("Aa");
+ EnumIndex e2 = es.insert("aa");
+ EnumIndex e3 = es.insert("aB");
+ DfaStringComparator cmp1(es.get_data_store(), "aa");
+ EXPECT_FALSE(cmp1.less(EnumIndex(), e1));
+ EXPECT_FALSE(cmp1.less(EnumIndex(), e2));
+ EXPECT_TRUE(cmp1.less(EnumIndex(), e3));
+ EXPECT_FALSE(cmp1.less(e1, EnumIndex()));
+ EXPECT_FALSE(cmp1.less(e2, EnumIndex()));
+ EXPECT_FALSE(cmp1.less(e3, EnumIndex()));
+ DfaStringComparator cmp2(es.get_data_store(), "Aa");
+ EXPECT_TRUE(cmp2.less(EnumIndex(), e1));
+ EXPECT_TRUE(cmp2.less(EnumIndex(), e2));
+ EXPECT_TRUE(cmp2.less(EnumIndex(), e3));
+ EXPECT_FALSE(cmp2.less(e1, EnumIndex()));
+ EXPECT_FALSE(cmp2.less(e2, EnumIndex()));
+ EXPECT_FALSE(cmp2.less(e3, EnumIndex()));
+}
+
}
GTEST_MAIN_RUN_ALL_TESTS()