From 68e0a13d573ade73cc2550edb25dade8fc10361e Mon Sep 17 00:00:00 2001 From: namark <namark@disroot.org> Date: Sun, 9 Aug 2020 01:50:44 +0400 Subject: [PATCH] Additional tests for tuple apply_for. --- unit_tests/tuple_utils.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/unit_tests/tuple_utils.cpp b/unit_tests/tuple_utils.cpp index a9be347..7d3fa70 100644 --- a/unit_tests/tuple_utils.cpp +++ b/unit_tests/tuple_utils.cpp @@ -33,9 +33,19 @@ int main() ss.str(""); ss.clear(); - auto t2 = std::tuple(0,1,2,3); + auto t2 = std::tuple(0,1.1,2,3); + + apply_for(2, [](auto&& x) + { x += 2; }, t2) ; + assert( std::tuple(0,1.1,4,3) == t2 ); + + apply_for({1, 3}, [](auto&& x) + { x += 2; }, t2) ; + assert( std::tuple(0,3.1,6,3) == t2 ); + + auto t3 = std::tuple(0,1,2,3); assert( 4 == apply_for(2, [](auto&& x) - { return x + 2; }, t2) ); + { return x + 2; }, t3) ); return 0; } -- GitLab