1 /* Copyright (C) 2016 Murray Cumming
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/
19 #include <sigc++/tuple-utils/tuple_cdr.h>
24 test_tuple_type_cdr() {
25 using type_tuple_isd = std::tuple<int, short, double>;
26 using type_tuple_sd = std::tuple<short, double>;
27 using type_tuple_suffix = sigc::internal::tuple_type_cdr<type_tuple_isd>::type;
29 static_assert(std::tuple_size<type_tuple_suffix>::value == 2,
30 "unexpected tuple_cdr()ed tuple size.");
31 static_assert(std::is_same<type_tuple_suffix, type_tuple_sd>::value,
32 "unexpected tuple_cdr()ed tuple type");
38 std::make_tuple(nullptr, std::string("hello"), std::string("world"));
39 auto t_suffix = sigc::internal::tuple_cdr(t_larger);
40 assert(std::get<0>(t_suffix) == "hello");
41 assert(std::get<1>(t_suffix) == "world");
43 using type_tuple_suffix = std::tuple<std::string, std::string>;
45 static_assert(std::tuple_size<decltype(t_suffix)>::value == 2,
46 "unexpected cdr()ed tuple size.");
47 static_assert(std::is_same<decltype(t_suffix), type_tuple_suffix>::value,
48 "unexpected cdr()ed tuple type");
52 test_tuple_cdr_stdref() {
53 std::string b = "yadda";
54 std::string c = "yaddayadda";
55 auto t_larger = std::make_tuple(1, std::ref(b), std::ref(c));
57 //std::cout << "debug: " << type(std::get<1>(t_larger)) << std::endl;
59 auto t_suffix = sigc::internal::tuple_cdr(t_larger);
62 //This works, but it's not what we are testing here:
63 //assert(std::get<1>(t_larger) == "hello");
65 assert(std::get<0>(t_suffix) == "hello");
66 assert(std::get<1>(t_suffix) == "world");
71 test_tuple_cdr_constexpr() {
72 constexpr auto str_hello = "hello";
73 constexpr auto str_world = "world";
75 constexpr auto t_larger =
76 std::make_tuple(nullptr, str_hello, str_world);
77 constexpr auto t_suffix = sigc::internal::tuple_cdr(t_larger);
78 assert(std::get<0>(t_suffix) == str_hello);
79 assert(std::get<1>(t_suffix) == str_world);
84 test_tuple_type_cdr();
86 test_tuple_cdr_stdref();
88 test_tuple_cdr_constexpr();