From e3ab5b19197122709f06636001955e8c84345a0f Mon Sep 17 00:00:00 2001 From: Geir Storli Date: Mon, 25 Feb 2019 15:06:43 +0000 Subject: Verify that previous value is used by testing with an operation that combines old and new. --- .../tensor_modify_operation_test.cpp | 25 +++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'eval/src') diff --git a/eval/src/tests/tensor/tensor_modify_operation/tensor_modify_operation_test.cpp b/eval/src/tests/tensor/tensor_modify_operation/tensor_modify_operation_test.cpp index 0b68088f93b..31f17b3eed2 100644 --- a/eval/src/tests/tensor/tensor_modify_operation/tensor_modify_operation_test.cpp +++ b/eval/src/tests/tensor/tensor_modify_operation/tensor_modify_operation_test.cpp @@ -1,5 +1,6 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include #include #include #include @@ -13,16 +14,6 @@ using vespalib::eval::TensorSpec; using vespalib::tensor::test::makeTensor; using namespace vespalib::tensor; -namespace { - -double -replace(double, double b) -{ - return b; -} - -} - void checkUpdate(const TensorSpec &source, const TensorSpec &update, const TensorSpec &expect) { @@ -30,7 +21,7 @@ checkUpdate(const TensorSpec &source, const TensorSpec &update, const TensorSpec auto updateTensor = makeTensor(update); const CellValues cellValues(*updateTensor); - auto actualTensor = sourceTensor->modify(replace, cellValues); + auto actualTensor = sourceTensor->modify(vespalib::eval::operation::Add::f, cellValues); auto actual = actualTensor->toSpec(); auto expectTensor = makeTensor(expect); auto expectPadded = expectTensor->toSpec(); @@ -45,7 +36,7 @@ TEST(TensorModifyTest, sparse_tensors_can_be_modified) TensorSpec("tensor(x{},y{})") .add({{"x","8"},{"y","9"}}, 2), TensorSpec("tensor(x{},y{})") - .add({{"x","8"},{"y","9"}}, 2) + .add({{"x","8"},{"y","9"}}, 13) .add({{"x","9"},{"y","9"}}, 11)); } @@ -57,7 +48,7 @@ TEST(TensorModifyTest, dense_tensors_can_be_modified) TensorSpec("tensor(x{},y{})") .add({{"x","8"},{"y","9"}}, 2), TensorSpec("tensor(x[10],y[10])") - .add({{"x",8},{"y",9}}, 2) + .add({{"x",8},{"y",9}}, 13) .add({{"x",9},{"y",9}}, 11)); } @@ -72,10 +63,10 @@ TEST(TensorModifyTest, mixed_tensors_can_be_modified) .add({{"x","a"},{"y","0"}}, 6) .add({{"x","b"},{"y","1"}}, 7), TensorSpec("tensor(x{},y[2])") - .add({{"x","a"},{"y",0}}, 6) + .add({{"x","a"},{"y",0}}, 8) .add({{"x","a"},{"y",1}}, 3) .add({{"x","b"},{"y",0}}, 4) - .add({{"x","b"},{"y",1}}, 7)); + .add({{"x","b"},{"y",1}}, 12)); } TEST(TensorModifyTest, sparse_tensors_ignore_updates_to_missing_cells) @@ -87,7 +78,7 @@ TEST(TensorModifyTest, sparse_tensors_ignore_updates_to_missing_cells) .add({{"x","7"},{"y","9"}}, 2) .add({{"x","8"},{"y","9"}}, 2), TensorSpec("tensor(x{},y{})") - .add({{"x","8"},{"y","9"}}, 2) + .add({{"x","8"},{"y","9"}}, 13) .add({{"x","9"},{"y","9"}}, 11)); } @@ -100,7 +91,7 @@ TEST(TensorModifyTest, dense_tensors_ignore_updates_to_out_of_range_cells) .add({{"x","8"},{"y","9"}}, 2) .add({{"x","10"},{"y","9"}}, 2), TensorSpec("tensor(x[10],y[10])") - .add({{"x",8},{"y",9}}, 2) + .add({{"x",8},{"y",9}}, 13) .add({{"x",9},{"y",9}}, 11)); } -- cgit v1.2.3