Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
20.tuple.rel.cpp
Go to the documentation of this file.
1
29#include <rw_driver.h>
30
31// compile out all test code if extensions disabled
32#if !defined (_RWSTD_NO_EXT_CXX_0X) \
33 && !defined (_RWSTD_NO_RVALUE_REFERENCES)
34
35#include <tuple>
36
37#include "20.tuple.h"
38
39
41static void
42test_eq ()
43{
44 rw_info (0, __FILE__, __LINE__, "operator==");
45
46 std::tuple<> nt1, nt2;
47 // special case
48 rw_assert (nt1 == nt1, __FILE__, __LINE__,
49 "nt1 == nt1, got false, expected true");
50
51#undef TEST
52#define TEST(expr) \
53 rw_assert (expr, __FILE__, __LINE__, #expr \
54 "; got %b, expected %b", !(expr), expr)
55
56 TEST (nt1 == nt2);
57
58 std::tuple<int> it1 (1), it2 (1), it3 (2);
59 TEST (it1 == it1);
60 TEST (it1 == it2);
61 TEST (!(it1 == it3));
62
63 UserDefined ud1 (1), ud2 (2);
64 std::tuple<UserDefined> ut1 (ud1), ut2 (ud1), ut3 (ud2);
65 TEST (ut1 == ut1);
66 TEST (ut1 == ut2);
67 TEST (!(ut1 == ut3));
68
69 std::tuple<bool, char, int, double, void*, UserDefined>
70 bt1 (true, 'a', 255, 3.14159, &nt1, ud1),
71 bt2 (true, 'a', 255, 3.14159, &nt1, ud1),
72 bt3 (true, 'a', 256, 3.14159, &nt1, ud1);
73 TEST (bt1 == bt1);
74 TEST (bt1 == bt2);
75 TEST (!(bt1 == bt3));
76}
77
78
80static void
81test_lt ()
82{
83 rw_info (0, __FILE__, __LINE__, "operator<");
84
85 std::tuple<> nt1, nt2;
86 TEST (!(nt1 < nt1));
87 TEST (!(nt1 < nt2));
88
89 std::tuple<int> it1 (1), it2 (2);
90 TEST (!(it1 < it1));
91 TEST (it1 < it2);
92
93 UserDefined ud1 (1), ud2 (2);
94 std::tuple<UserDefined> ut1 (ud1), ut2 (ud2);
95 TEST (!(ut1 < ut1));
96 TEST (ut1 < ut2);
97
98 std::tuple<long, const char*> pt1 (1234L, "string");
99 TEST (!(pt1 < pt1));
100 std::tuple<long, const char*> pt2 (1235L, "string");
101 TEST (pt1 < pt2);
102 std::tuple<long, const char*> pt3 (1234L, "strings");
103 TEST (pt1 < pt3);
104
105 std::tuple<bool, char, int, double, void*, UserDefined>
106 bt1 (true, 'a', 255, 3.14159, &nt1, ud1),
107 bt2 (true, 'a', 256, 3.14159, &nt1, ud1),
108 bt3 (true, 'a', 255, 3.14159, &nt1, ud2);
109 rw_assert (!(bt1 < bt1), __FILE__, __LINE__,
110 "bt1 < bt1, got true, expected false");
111 rw_assert (bt1 < bt2, __FILE__, __LINE__,
112 "bt1 < bt2, got false, expected true");
113 rw_assert (bt1 < bt3, __FILE__, __LINE__,
114 "bt1 < bt3, got false, expected true");
115}
116
117
119static int
120run_test (int /*argc*/, char* /*argv*/ [])
121{
122 test_eq ();
123 test_lt ();
124
125 //test_ne ();
126 //test_gt ();
127 //test_le ();
128 //test_ge ();
129
130 return 0;
131}
132
133#else // _RWSTD_NO_EXT_CXX_0X || _RWSTD_NO_RVALUE_REFERENCES
134
135static int
136run_test (int, char*[])
137{
138
139#if defined (_RWSTD_NO_RVALUE_REFERENCES)
140
141 rw_warn (0, 0, __LINE__,
142 "test disabled because _RWSTD_NO_EXT_CXX_OX is defined");
143
144#elif defined (_RWSTD_NO_RVALUE_REFERENCES)
145
146 rw_warn (0, 0, __LINE__,
147 "test disabled because _RWSTD_NO_RVALUE_REFERENCES is "
148 "defined");
149
150#endif
151
152 return 0;
153}
154
155#endif // _RWSTD_NO_EXT_CXX_0X || _RWSTD_NO_RVALUE_REFERENCES
156
157/*extern*/ int
158main (int argc, char* argv [])
159{
160 return rw_test (argc, argv, __FILE__,
161 "[tuple.rel]", "20.3.1.6 Relational operators",
162 run_test, "", 0);
163}
164
#define TEST(expr)
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
#define main
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_info(int, const char *, int, const char *,...)
Definition driver.cpp:1681
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
Definition driver.cpp:1630
_TEST_EXPORT int rw_warn(int, const char *, int, const char *,...)
Definition driver.cpp:1647