summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/features/constant/constant_test.cpp
diff options
context:
space:
mode:
authorHaavard <havardpe@yahoo-inc.com>2016-10-27 11:32:53 +0000
committerHaavard <havardpe@yahoo-inc.com>2016-11-03 10:08:30 +0000
commit8b9497d62e322e8b546a975c8c804a1523235d7e (patch)
tree30e595f03256af3cd8b1464a84782927f8d5d077 /searchlib/src/tests/features/constant/constant_test.cpp
parentb5f37072d3dcf11efe77a57cc7f8cd2641348f5b (diff)
avoid verbatim tensors
Diffstat (limited to 'searchlib/src/tests/features/constant/constant_test.cpp')
-rw-r--r--searchlib/src/tests/features/constant/constant_test.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/searchlib/src/tests/features/constant/constant_test.cpp b/searchlib/src/tests/features/constant/constant_test.cpp
index 6cae122d8c8..ee7e4a7e353 100644
--- a/searchlib/src/tests/features/constant/constant_test.cpp
+++ b/searchlib/src/tests/features/constant/constant_test.cpp
@@ -1,14 +1,14 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/fastos.h>
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/vespalib/eval/function.h>
#include <vespa/searchlib/features/setup.h>
#include <vespa/searchlib/fef/fef.h>
-#include <vespa/searchlib/fef/test/as_tensor.h>
#include <vespa/searchlib/fef/test/ftlib.h>
#include <vespa/searchlib/fef/test/indexenvironment.h>
+#include <vespa/vespalib/eval/function.h>
+#include <vespa/vespalib/eval/tensor_spec.h>
#include <vespa/vespalib/tensor/default_tensor.h>
+#include <vespa/vespalib/tensor/default_tensor_engine.h>
#include <vespa/vespalib/tensor/tensor_factory.h>
using search::feature_t;
@@ -20,7 +20,9 @@ using vespalib::eval::Function;
using vespalib::eval::Value;
using vespalib::eval::DoubleValue;
using vespalib::eval::TensorValue;
+using vespalib::eval::TensorSpec;
using vespalib::eval::ValueType;
+using vespalib::tensor::DefaultTensorEngine;
using vespalib::tensor::DenseTensorCells;
using vespalib::tensor::Tensor;
using vespalib::tensor::TensorCells;
@@ -36,6 +38,11 @@ Tensor::UP createTensor(const TensorCells &cells,
return TensorFactory::create(cells, dimensions, builder);
}
+Tensor::UP make_tensor(const TensorSpec &spec) {
+ auto tensor = DefaultTensorEngine::ref().create(spec);
+ return Tensor::UP(dynamic_cast<Tensor*>(tensor.release()));
+}
+
}
struct ExecFixture
@@ -103,7 +110,11 @@ TEST_F("require that existing tensor constant is detected",
{{{"x", "c"}}, 7} },
{ "x" });
EXPECT_TRUE(f.setup());
- EXPECT_EQUAL(AsTensor("{ {x:b}:5, {x:c}:7, {x:a}:3 }"), f.executeTensor());
+ auto expect = make_tensor(TensorSpec("tensor(x{})")
+ .add({{"x","b"}}, 5)
+ .add({{"x","c"}}, 7)
+ .add({{"x","a"}}, 3));
+ EXPECT_EQUAL(*expect, f.executeTensor());
}