summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2021-06-18 11:52:36 +0000
committerArne Juul <arnej@verizonmedia.com>2021-06-18 11:52:36 +0000
commit8addadee33fa62205620d863e5984d559d165ed4 (patch)
treee537786e169a31b119c88a8b4f7140cc0325c25b /searchlib
parentb5a61790b9ee966ca92d7c40645899241e72ccff (diff)
also test tensorFromLabels with single-value integer attribute
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/features/tensor_from_labels/tensor_from_labels_test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/searchlib/src/tests/features/tensor_from_labels/tensor_from_labels_test.cpp b/searchlib/src/tests/features/tensor_from_labels/tensor_from_labels_test.cpp
index 2e83d2acbf2..8d202100699 100644
--- a/searchlib/src/tests/features/tensor_from_labels/tensor_from_labels_test.cpp
+++ b/searchlib/src/tests/features/tensor_from_labels/tensor_from_labels_test.cpp
@@ -95,6 +95,7 @@ struct ExecFixture
attrs.push_back(AttributeFactory::createAttribute("astr", AVC(AVBT::STRING, AVCT::ARRAY)));
attrs.push_back(AttributeFactory::createAttribute("aint", AVC(AVBT::INT32, AVCT::ARRAY)));
attrs.push_back(AttributeFactory::createAttribute("wsstr", AVC(AVBT::STRING, AVCT::WSET)));
+ attrs.push_back(AttributeFactory::createAttribute("sint", AVC(AVBT::INT32, AVCT::SINGLE)));
for (const auto &attr : attrs) {
attr->addReservedDoc();
@@ -112,6 +113,9 @@ struct ExecFixture
aint->append(1, 3, 0);
aint->append(1, 5, 0);
aint->append(1, 7, 0);
+
+ IntegerAttribute *sint = static_cast<IntegerAttribute *>(attrs[3].get());
+ sint->update(1, 5);
for (const auto &attr : attrs) {
attr->commit();
@@ -167,6 +171,20 @@ TEST_F("require that array attribute can be converted to tensor (explicit dimens
.add({{"dim", "5"}}, 1)), f.execute());
}
+TEST_F("require that single-value integer attribute can be converted to tensor (default dimension)",
+ ExecFixture("tensorFromLabels(attribute(sint))"))
+{
+ EXPECT_EQUAL(*make_tensor(TensorSpec("tensor(sint{})")
+ .add({{"sint", "5"}}, 1)), f.execute());
+}
+
+TEST_F("require that single-value integer attribute can be converted to tensor (explicit dimension)",
+ ExecFixture("tensorFromLabels(attribute(sint),foobar)"))
+{
+ EXPECT_EQUAL(*make_tensor(TensorSpec("tensor(foobar{})")
+ .add({{"foobar", "5"}}, 1)), f.execute());
+}
+
TEST_F("require that empty tensor is created if attribute does not exists",
ExecFixture("tensorFromLabels(attribute(null))"))
{