diff options
author | Tor Egge <Tor.Egge@oath.com> | 2018-09-07 12:19:59 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@oath.com> | 2018-09-07 12:19:59 +0000 |
commit | 95a03afcc6b764e089c286ebc117f5a9e517e951 (patch) | |
tree | 4e44a8dfc6cce9a7e31a69af5d893ed5bd92551c /searchlib/src/tests/expression/attributenode | |
parent | 9aa385c95449551b1dc111ba85e8b68de5cbbcd5 (diff) |
Add support for indirect map lookup key.
Diffstat (limited to 'searchlib/src/tests/expression/attributenode')
-rw-r--r-- | searchlib/src/tests/expression/attributenode/attribute_node_test.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/searchlib/src/tests/expression/attributenode/attribute_node_test.cpp b/searchlib/src/tests/expression/attributenode/attribute_node_test.cpp index 8ad53fea0f0..c92b5fc4808 100644 --- a/searchlib/src/tests/expression/attributenode/attribute_node_test.cpp +++ b/searchlib/src/tests/expression/attributenode/attribute_node_test.cpp @@ -93,6 +93,8 @@ AttributeManagerFixture::AttributeManagerFixture() buildFloatArrayAttribute("smap.value.fval", {{ 110.0}, { 120.0, 121.0 }, {}}); buildStringArrayAttribute("map.key", {{"k1.1", "k1.2"}, {"k2"}, {}}); buildStringArrayAttribute("map.value", {{"n1.1", "n1.2"}, {"n2"}, {}}); + buildStringAttribute("keyfield1", {"k1.2", "k2", "k3"}); + buildStringAttribute("keyfield2", {"k1.1", "k1", "k1"}); } AttributeManagerFixture::~AttributeManagerFixture() = default; @@ -410,6 +412,18 @@ TEST_F("test keyed values", Fixture) TEST_DO(f.assertStrings({"", "", ""}, "map{\"k5\"}")); } +TEST_F("test indirectly keyed values", Fixture) +{ + TEST_DO(f.assertStrings({"n1.2", "n2", ""}, "map{attribute(keyfield1)}")); + TEST_DO(f.assertStrings({"n1.1", "", ""}, "map{attribute(keyfield2)}")); + TEST_DO(f.assertStrings({"n1.2", "n2", ""}, "smap{attribute(keyfield1)}.name")); + TEST_DO(f.assertStrings({"n1.1", "", ""}, "smap{attribute(keyfield2)}.name")); + TEST_DO(f.assertFloats({ getUndefined<double>(), 120.0, getUndefined<double>()}, "smap{attribute(keyfield1)}.fval")); + TEST_DO(f.assertFloats({ 110.0, getUndefined<double>(), getUndefined<double>()}, "smap{attribute(keyfield2)}.fval")); + TEST_DO(f.assertInts({ 11, 20, getUndefined<int8_t>()}, "smap{attribute(keyfield1)}.val")); + TEST_DO(f.assertInts({ 10, getUndefined<int8_t>(), getUndefined<int8_t>()}, "smap{attribute(keyfield2)}.val")); +} + } TEST_MAIN() { TEST_RUN_ALL(); } |