Skip to content

Commit d2c938c

Browse files
committed
Added simple chain test
1 parent 8ae072a commit d2c938c

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

test/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SOURCES=$(shell find $(SRCD) -name '*.cpp')
22
DEPS=$(SOURCES:$(SRCD)/%.cpp=$(OBJD)/%.d)
3-
TESTS=generator sources manip aggreg stream
3+
TESTS=generator sources manip aggreg stream chain
44
TESTOBJ=$(TESTS:%=$(OBJD)/test_%.o)
55

66
CONAN_PKG_OVERRIDE=gtest

test/src/test_chain.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,33 @@
44
#include "sources.hpp"
55
#include "gmock/gmock.h"
66
#include "gtest/gtest.h"
7+
8+
using namespace fpgen;
9+
10+
template <typename T1, typename T2>
11+
std::ostream &operator<<(std::ostream &in, std::tuple<T1, T2> &other) {
12+
return in << "{ " << std::get<0>(other) << ", " << std::get<1>(other) << " }";
13+
}
14+
15+
TEST(chain, simple_chain) {
16+
/*
17+
Chain:
18+
-> [0..] -> [5..] -> [5..13] -> [15...169] \
19+
-> {[15...169], ['h'...'p']}
20+
-> [0..] -> [7..] -> [7..22] -> ['h'...'w'] /
21+
*/
22+
auto gen =
23+
map(take(drop(inc((size_t)0), 5), 9), [](size_t in) { return in * in; });
24+
25+
auto second = map(take(drop(inc((size_t)0), 7), 22),
26+
[](size_t in) { return (char)('a' + (in % 26)); });
27+
28+
size_t value = 5;
29+
for (auto v : zip(gen, second)) {
30+
EXPECT_EQ(value * value, std::get<0>(v));
31+
EXPECT_EQ('a' + 2 + value, std::get<1>(v));
32+
EXPECT_TRUE(value <= 13);
33+
value++;
34+
}
35+
EXPECT_EQ(value, 14);
36+
}

0 commit comments

Comments
 (0)