aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahoo-inc.com>2017-01-18 14:53:31 +0000
committerTor Egge <Tor.Egge@yahoo-inc.com>2017-01-18 14:59:59 +0000
commit2775b05f9e94fc1c4a3f217ad0a75bcc6cf67479 (patch)
treee0b84297a39e91b483ae9de49f38be7f5a501765 /searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp
parentac728c6a77543ea618bee127221f950670e84eb8 (diff)
Use serialized tensors in docsum blobs instead of slime objects.
Pass tensors as serialized tensors in slime version of docsum blob.
Diffstat (limited to 'searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp')
-rw-r--r--searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp
index e9496093cfe..27a50c9c57f 100644
--- a/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp
+++ b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp
@@ -150,6 +150,7 @@ class Test : public vespalib::TestApp {
void checkString(const string &str, const FieldValue *value);
void checkData(const search::RawBuf &data, const FieldValue *value);
+ void checkTensor(const Tensor::UP &tensor, const FieldValue *value);
template <unsigned int N>
void checkArray(const char *(&str)[N], const FieldValue *value);
void setSummaryField(const string &name);
@@ -170,7 +171,7 @@ class Test : public vespalib::TestApp {
void requireThatSearchDataTypeUsesDefaultDataTypes();
void requireThatLinguisticsAnnotationUsesDefaultDataTypes();
void requireThatPredicateIsPrinted();
- void requireThatTensorIsPrinted();
+ void requireThatTensorIsNotConverted();
const DocumentType &getDocType() const { return *_documentType; }
Document makeDocument();
StringFieldValue annotateTerm(const string &term);
@@ -245,7 +246,7 @@ Test::Main()
TEST_CALL(requireThatSearchDataTypeUsesDefaultDataTypes());
TEST_CALL(requireThatLinguisticsAnnotationUsesDefaultDataTypes());
TEST_CALL(requireThatPredicateIsPrinted());
- TEST_CALL(requireThatTensorIsPrinted());
+ TEST_CALL(requireThatTensorIsNotConverted());
TEST_DONE();
}
@@ -430,6 +431,17 @@ void Test::checkData(const search::RawBuf &buf, const FieldValue *value) {
EXPECT_TRUE(memcmp(buf.GetDrainPos(), got.first, got.second) == 0);
}
+void Test::checkTensor(const Tensor::UP &tensor, const FieldValue *value) {
+ ASSERT_TRUE(value);
+ const TensorFieldValue *s = dynamic_cast<const TensorFieldValue *>(value);
+ ASSERT_TRUE(s);
+ const Tensor::UP &tvalue = s->getAsTensorPtr();
+ EXPECT_EQUAL(tensor.get() != nullptr, tvalue.get() != nullptr);
+ if (tensor) {
+ EXPECT_EQUAL(*tensor, *tvalue);
+ }
+}
+
template <unsigned int N>
void Test::checkArray(const char *(&str)[N], const FieldValue *value) {
ASSERT_TRUE(value);
@@ -649,7 +661,7 @@ createTensor(const TensorCells &cells, const TensorDimensions &dimensions) {
}
void
-Test::requireThatTensorIsPrinted()
+Test::requireThatTensorIsNotConverted()
{
TensorFieldValue tensorFieldValue;
tensorFieldValue = createTensor({ {{{"x", "4"}, {"y", "5"}}, 7} },
@@ -658,30 +670,17 @@ Test::requireThatTensorIsPrinted()
doc.setRepo(*_documentRepo);
doc.setValue("tensor", tensorFieldValue);
- FieldBlock expect1("{ dimensions: [ 'x', 'y' ], cells: ["
- "{ address: { x:'4', y:'5' }, value: 7.0 }"
- "] }");
-
- TEST_CALL(checkString(expect1.json,
+ TEST_CALL(checkTensor(createTensor({ {{{"x", "4"}, {"y", "5"}}, 7} },
+ {"x", "y"}),
SFC::convertSummaryField(false,
*doc.getValue("tensor"),
- false).get()));
- TEST_CALL(checkData(expect1.binary,
- SFC::convertSummaryField(false,
- *doc.getValue("tensor"),
- true).get()));
+ true).get()));
doc.setValue("tensor", TensorFieldValue());
- FieldBlock expect2("{ }");
-
- TEST_CALL(checkString(expect2.json,
+ TEST_CALL(checkTensor(Tensor::UP(),
SFC::convertSummaryField(false,
*doc.getValue("tensor"),
- false).get()));
- TEST_CALL(checkData(expect2.binary,
- SFC::convertSummaryField(false,
- *doc.getValue("tensor"),
- true).get()));
+ true).get()));
}
} // namespace