diff options
author | dec05eba <0xdec05eba@gmail.com> | 2018-07-20 23:34:50 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-07-20 23:39:23 +0200 |
commit | 142a28cb61c530227833c092273ce9d188faf6a8 (patch) | |
tree | 1c9c30626f12f3d0f3d021934c350c0556b7401f /tests/main.cpp | |
parent | e1250f0525a16c5c409680f7c6acf735b4a8a416 (diff) |
Initial commit
Diffstat (limited to 'tests/main.cpp')
-rw-r--r-- | tests/main.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 0000000..dfcd357 --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,47 @@ +#include <cstdio> +#include <cstdlib> +#include <vector> +#include <sibs/Functional.hpp> + +void assertEquals(int expected, int actual) +{ + if(actual != expected) + { + fprintf(stderr, "Assert failed: Expected %d, got %d\n", expected, actual); + exit(1); + } +} + +int main(int argc, char **argv) +{ + std::vector<int> vec1 = { 1, 2, 3, 4, 5 }; + std::vector<int> vec2 = { 6, 7, 8, 9, 10 }; + int sum = 0; + + sibs::Function<int> func1(vec1.data(), vec1.data() + vec1.size()); + for(auto value : func1) + { + printf("func1 value: %d\n", value); + sum += value; + } + assertEquals(15, sum); + sum = 0; + + sibs::Function<int> func2(vec2); + for(auto value : func2) + { + printf("func2 value: %d\n", value); + sum += value; + } + assertEquals(40, sum); + sum = 0; + + for(auto value : func1.merge(func2)) + { + printf("func1 and func2 value: %d\n", value); + sum += value; + } + assertEquals(55, sum); + + return 0; +} |