MCPcopy Create free account
hub / github.com/davisking/dlib / tuple_test

Function tuple_test

dlib/test/tuple.cpp:68–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 }
67
68 void tuple_test (
69 )
70 /*!
71 ensures
72 - runs tests on tuple functions for compliance with the specs
73 !*/
74 {
75
76 print_spinner();
77
78 using dlib::tuple;
79
80 tuple<> a;
81 tuple<int> b;
82 tuple<int, float> c;
83
84
85 a.get<1>();
86 a.get<2>();
87 a.get<3>();
88 a.get<4>();
89 a.get<5>();
90
91 check_nonconst(b);
92 check_nonconst(c);
93 check_const(b);
94 check_const(c);
95
96 COMPILE_TIME_ASSERT((is_same_type<tuple<>::get_type<0>::type, null_type>::value));
97 COMPILE_TIME_ASSERT((is_same_type<tuple<int>::get_type<0>::type, int>::value));
98 COMPILE_TIME_ASSERT((is_same_type<tuple<int,float>::get_type<0>::type, int>::value));
99 COMPILE_TIME_ASSERT((is_same_type<tuple<int,float>::get_type<1>::type, float>::value));
100 COMPILE_TIME_ASSERT((is_same_type<tuple<int,float>::get_type<2>::type, null_type>::value));
101
102 b.get<0>() = 8;
103 DLIB_TEST(b.get<int>() == 8);
104 DLIB_TEST(b.index<int>() == 0);
105
106 c.get<0>() = 9;
107 DLIB_TEST(c.get<int>() == 9);
108 DLIB_TEST(c.index<int>() == 0);
109 c.get<1>() = 3.0;
110 DLIB_TEST(c.get<float>() == 3.0);
111 DLIB_TEST(c.index<float>() == 1);
112
113
114
115 {
116 typedef tuple<int, short, long> T;
117 T a, b;
118 a.get<0>() = 1;
119 a.get<1>() = 3;
120 a.get<2>() = 2;
121
122 b = a;
123
124 inc i;
125 s_nil n;

Callers 1

perform_testMethod · 0.85

Calls 11

print_spinnerFunction · 0.85
check_nonconstFunction · 0.85
check_constFunction · 0.85
incClass · 0.85
s_nilClass · 0.85
for_eachMethod · 0.80
for_indexMethod · 0.80
serializeFunction · 0.70
deserializeFunction · 0.70
swapFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected