From 02c6e34f9859047efe702cf5b866702f7b02d878 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 18 Jan 2015 19:58:35 +0100 Subject: Implemented `Map` in terms of `Fold` * as its name implies this _function_ applies a given _function_ to each element of a _Cons_ structure * added appropriate test case --- test.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test.cc') diff --git a/test.cc b/test.cc index e642b3a..6b9dffb 100644 --- a/test.cc +++ b/test.cc @@ -3,12 +3,17 @@ #include "type.h" #include "operation/math.h" #include "conditional/if.h" + #include "list/cons.h" #include "list/list.h" #include "list/operation/higher/fold.h" +#include "list/operation/higher/misc.h" class TypeAsValueTest : public ::testing::Test { }; +template +using quadruple = tav::Multiply, Element>; + TEST_F(TypeAsValueTest, BasicMath) { // (+ 1 2) EXPECT_EQ(3, ( tav::Add, tav::Int<2>>::value )); @@ -89,6 +94,11 @@ TEST_F(TypeAsValueTest, ListFold) { EXPECT_EQ(6, ( tav::Fold, tav::List, tav::Int<2>, tav::Int<3>>::type>::type::value )); } +TEST_F(TypeAsValueTest, ListMap) { + // (map quadruple (list 1 2 3)) + EXPECT_TRUE(( std::is_same, tav::Int<8>, tav::Int<12>>::type, tav::Map, tav::Int<2>, tav::Int<3>>::type>::type>::value )); +} + int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); -- cgit v1.2.3