also test tensorFromLabels with single-value integer attribute
@@ -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();
@@ -113,6 +114,9 @@ struct ExecFixture
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))"))
{
