diff options
author | Adrian Kummerlaender | 2015-01-18 13:58:36 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-01-18 13:58:36 +0100 |
commit | 7574e3836eec13e6f632b811e6bf001f2e3d2a1d (patch) | |
tree | 4ebdaf0cd82082678de8733a4f2724e2b3946dc9 /test.cc | |
parent | 8943b2e30f8275619df0cf89f1e8ebc7deb58ca5 (diff) | |
download | TypeAsValue-7574e3836eec13e6f632b811e6bf001f2e3d2a1d.tar TypeAsValue-7574e3836eec13e6f632b811e6bf001f2e3d2a1d.tar.gz TypeAsValue-7574e3836eec13e6f632b811e6bf001f2e3d2a1d.tar.bz2 TypeAsValue-7574e3836eec13e6f632b811e6bf001f2e3d2a1d.tar.lz TypeAsValue-7574e3836eec13e6f632b811e6bf001f2e3d2a1d.tar.xz TypeAsValue-7574e3836eec13e6f632b811e6bf001f2e3d2a1d.tar.zst TypeAsValue-7574e3836eec13e6f632b811e6bf001f2e3d2a1d.zip |
Implemented higher order function `fold`
* applies a given _function_ to each _Cons_ starting with a initial value
* added appropriate test case
Diffstat (limited to 'test.cc')
-rw-r--r-- | test.cc | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -5,6 +5,7 @@ #include "conditional/if.h" #include "list/cons.h" #include "list/list.h" +#include "list/operation/higher/fold.h" class TypeAsValueTest : public ::testing::Test { }; @@ -83,6 +84,11 @@ TEST_F(TypeAsValueTest, ListConcatenate) { EXPECT_EQ(2, ( tav::Head<tav::Tail<tav::Concatenate<tav::List<tav::Int<1>>::type, tav::List<tav::Int<2>>::type>::type>>::value )); } +TEST_F(TypeAsValueTest, ListFold) { + // (fold + 0 (list 1 2 3)) + EXPECT_EQ(6, ( tav::Fold<tav::Add, tav::Int<0>, tav::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>::type>::type::value )); +} + int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); |