aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2020-01-30 13:07:45 +0000
committerTor Brede Vekterli <vekterli@verizonmedia.com>2020-01-31 11:33:08 +0100
commit4c6c916212641e4759f85e9e598777c260932f23 (patch)
tree2d984980cc8be71dfb2fb9ea65fa499059ea587d /searchlib/src/tests
parenta3d50fb4b8ea0e6cea01d9283d7029d7ed88fb3c (diff)
Forward isUndefined() for imported attributes to the target attribute vector
Default implementation would always return false, which means that the undefined sentinel value would be returned to--and used by--the caller.
Diffstat (limited to 'searchlib/src/tests')
-rw-r--r--searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp b/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp
index cfa05b7a765..48a06bec9e8 100644
--- a/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp
+++ b/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp
@@ -219,6 +219,15 @@ TEST_F("Weighted floating point attribute values can be retrieved via reference"
assert_multi_value_matches<WeightedFloat>(f, DocId(3), doc7_values);
}
+TEST_F("isUndefined() works for primitive attribute type", Fixture) {
+ reset_with_single_value_reference_mappings<IntegerAttribute, int32_t>(
+ f, BasicType::INT32,
+ {{DocId(3), dummy_gid(7), DocId(7), 5678}});
+
+ EXPECT_FALSE(f.get_imported_attr()->isUndefined(DocId(3))); // Mapped
+ EXPECT_TRUE(f.get_imported_attr()->isUndefined(DocId(2))); // Not mapped
+}
+
struct SingleStringAttrFixture : Fixture {
SingleStringAttrFixture() : Fixture() {
setup();
@@ -255,6 +264,11 @@ TEST_F("findEnum() returns target vector enum via reference", SingleStringAttrFi
EXPECT_EQUAL(expected_handle, actual_handle);
}
+TEST_F("isUndefined() works for enumerated attribute type", SingleStringAttrFixture) {
+ EXPECT_FALSE(f.get_imported_attr()->isUndefined(DocId(2))); // Mapped
+ EXPECT_TRUE(f.get_imported_attr()->isUndefined(DocId(3))); // Not mapped
+}
+
// Note: assumes that fixture has set up a string enum of value "foo" in target attribute
template <typename FixtureType>
void verify_get_string_from_enum_is_mapped(FixtureType& f) {