summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/features/constant
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahoo-inc.com>2016-08-30 15:35:34 +0000
committerTor Egge <Tor.Egge@yahoo-inc.com>2016-08-30 15:35:34 +0000
commit9a8ec2228b0f4300fc2cefb7cbe05ddbc2636e2f (patch)
treeae7a19d9d4fc3a3446f7c43f83953c79e3fb9c30 /searchlib/src/tests/features/constant
parentb019298bef4bf5cb6a8800a3e151f151f9d1b577 (diff)
Factor out AsTensor and AsEmptyTensor to test library.
Return error value when constant is not found. Use emplace when inserting into map. Correct comments.
Diffstat (limited to 'searchlib/src/tests/features/constant')
-rw-r--r--searchlib/src/tests/features/constant/constant_test.cpp27
1 files changed, 1 insertions, 26 deletions
diff --git a/searchlib/src/tests/features/constant/constant_test.cpp b/searchlib/src/tests/features/constant/constant_test.cpp
index aae22213861..3fae07f908a 100644
--- a/searchlib/src/tests/features/constant/constant_test.cpp
+++ b/searchlib/src/tests/features/constant/constant_test.cpp
@@ -5,11 +5,10 @@
#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/interpreted_function.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;
@@ -18,12 +17,10 @@ using namespace search::fef::indexproperties;
using namespace search::fef::test;
using namespace search::features;
using vespalib::eval::Function;
-using vespalib::eval::InterpretedFunction;
using vespalib::eval::Value;
using vespalib::eval::DoubleValue;
using vespalib::eval::TensorValue;
using vespalib::eval::ValueType;
-using vespalib::tensor::DefaultTensorEngine;
using vespalib::tensor::DenseTensorCells;
using vespalib::tensor::Tensor;
using vespalib::tensor::TensorCells;
@@ -90,28 +87,6 @@ struct ExecFixture
}
};
-struct AsTensor {
- InterpretedFunction ifun;
- InterpretedFunction::Context ctx;
- const Value *result;
- const Tensor *tensor;
- explicit AsTensor(const vespalib::string &expr)
- : ifun(DefaultTensorEngine::ref(), Function::parse(expr)), ctx(), result(&ifun.eval(ctx))
- {
- ASSERT_TRUE(result->is_tensor());
- tensor = static_cast<const Tensor *>(result->as_tensor());
- }
- bool operator==(const Tensor &rhs) const {
- return tensor->equals(rhs);
- }
-};
-
-std::ostream &operator<<(std::ostream &os, const AsTensor &my_tensor) {
- os << my_tensor.result->as_tensor();
- return os;
-}
-
-
TEST_F("require that missing constant is detected",
ExecFixture("constant(foo)"))
{