libcruft-util/test/tuple/value.cpp

42 lines
872 B
C++
Raw Normal View History

2018-04-05 13:54:42 +10:00
#include "tap.hpp"
#include "tuple/value.hpp"
int
main (void)
{
util::TAP::logger tap;
{
auto tuple = std::make_tuple (1,2,3,4);
std::vector<int> expected {{ 1, 2, 3, 4 }};
std::vector<int> actual;
util::tuple::value::each ([&actual] (auto i) { actual.push_back (i); }, tuple);
tap.expect_eq (actual, expected, "value iteration");
}
{
std::tuple a (1, 2);
std::array<char,2> b { 'a', 'b' };
std::tuple c (
std::tuple(1, 'a'),
std::tuple(2, 'b')
);
tap.expect_eq (c, util::tuple::value::zip (a, b), "tuple zipping");
}
2018-04-05 16:06:09 +10:00
{
std::tuple a (1, 2);
auto result = util::tuple::value::reverse (a);
std::tuple expected (2, 1);
tap.expect_eq (result, expected, "tuple reverse");
}
2018-04-05 13:54:42 +10:00
return tap.status ();
}