commit 574ab94386d7a4644fe741d17e3f7d81b6289cdf
parent 2ccc349f8bf492174a944105cf26c793e46053b2
Author: [email protected] <[email protected]>
Date: Sun, 21 Oct 2018 17:39:00 +0300
Tests for placeholders
Diffstat:
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/tests/expression_test.cpp b/tests/expression_test.cpp
@@ -63,12 +63,28 @@ TEST(test_arg_replace)
{
univector<float, 10> v1 = counter();
univector<float, 10> v2 = -counter();
- auto e1 = to_pointer(v1) * 10;
- std::get<0>(e1.args) = to_pointer(v2);
+ auto e1 = to_pointer(v1) * 10;
+ std::get<0>(e1.args) = to_pointer(v2);
CHECK_EXPRESSION(e1, 10, [](size_t i) { return i * -10.0; });
}
+TEST(placeholders)
+{
+ auto expr = 100 * placeholder<float>();
+ CHECK_EXPRESSION(expr, infinite_size, [](size_t) { return 0.f; });
+ substitute(expr, to_pointer(counter<float>()));
+ CHECK_EXPRESSION(expr, infinite_size, [](size_t i) { return 100.f * i; });
+}
+
+TEST(placeholders_pointer)
+{
+ expression_pointer<float> expr = to_pointer(10 * placeholder<float>());
+ CHECK_EXPRESSION(expr, infinite_size, [](size_t) { return 0.f; });
+ substitute(expr, to_pointer(counter<float>()));
+ CHECK_EXPRESSION(expr, infinite_size, [](size_t i) { return 10.f * i; });
+}
+
TEST(size_calc)
{
auto a = counter();
@@ -99,7 +115,7 @@ TEST(partition)
{
{
univector<double, 400> output = zeros();
- auto result = partition(output, counter(), 5, 1);
+ auto result = partition(output, counter(), 5, 1);
CHECK(result.count == 5);
CHECK(result.chunk_size == 80);
@@ -117,7 +133,7 @@ TEST(partition)
{
univector<double, 400> output = zeros();
- auto result = partition(output, counter(), 5, 160);
+ auto result = partition(output, counter(), 5, 160);
CHECK(result.count == 3);
CHECK(result.chunk_size == 160);