From a9ec2e4e13670c8084c6baae59d6f3631960e22c Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 31 Jan 2015 12:04:34 +0100 Subject: Implemented higher order `Find` list search operation * added appropriate test case * other queries in `query.h` may be redefined in terms of `Find` --- test.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test.cc') diff --git a/test.cc b/test.cc index 9168038..014a974 100644 --- a/test.cc +++ b/test.cc @@ -11,6 +11,7 @@ #include "list/operation/higher/filter.h" #include "list/operation/higher/partition.h" #include "list/operation/higher/query.h" +#include "list/operation/higher/find.h" #include "list/generator/iota.h" #include "list/generator/make_list.h" #include "list/generator/higher/list_tabulate.h" @@ -682,6 +683,41 @@ static_assert( "(count even? (list 1 3 5)) != 0" ); +//list find + +static_assert( + std::is_same< + tav::Int<4>, + tav::Find< + tav::Even, + tav::List, tav::Int<3>, tav::Int<4>, tav::Int<6>>::type + >::type + >::value, + "(find even? (list 1 3 4 6)) != 4" +); + +static_assert( + std::is_same< + tav::Int<6>, + tav::Find< + tav::Even, + tav::List, tav::Int<3>, tav::Int<5>, tav::Int<6>>::type + >::type + >::value, + "(find even? (list 1 3 5 6)) != 6" +); + +static_assert( + std::is_same< + tav::Boolean, + tav::Find< + tav::Even, + tav::List, tav::Int<3>, tav::Int<5>>::type + >::type + >::value, + "(find even? (list 1 3 5)) != #f" +); + // function apply static_assert( -- cgit v1.2.3