Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
20.meta.trans.ref.cpp
Go to the documentation of this file.
1// -*- C++ -*-
2
30#include <rw_driver.h>
31#include <rw/_defs.h>
32
33// compile out all test code if extensions disabled
34#ifndef _RWSTD_NO_EXT_CXX_0X
35
36#include <type_traits>
37
38
40class class_t;
41
42void test_trait (int line, const char* trait,
43 const char* typeT, const char* typeU,
44 bool success)
45{
46 rw_assert (success, 0, line,
47 "%s<%s>::type is %{?}exactly%{:}not%{;} %s",
48 trait, typeT, success, typeU);
49}
50
51#define TEST(Trait,TypeT,TypeU) \
52 test_trait(__LINE__, #Trait, #TypeT, #TypeU, \
53 std::is_same<Trait<TypeT>::type, TypeU>::value)
54
55
57static void test_add_lvalue_reference ()
58{
59 TEST (std::add_lvalue_reference, int, int&);
60 TEST (std::add_lvalue_reference, int&, int&);
61
62 TEST (std::add_lvalue_reference, void, void);
63
64 TEST (std::add_lvalue_reference, int const [1], int const (&) [1]);
65 TEST (std::add_lvalue_reference, int const (&) [1], int const (&) [1]);
66
67 TEST (std::add_lvalue_reference, int const * volatile,
68 int const * volatile &);
69 TEST (std::add_lvalue_reference, int const * volatile &,
70 int const * volatile &);
71
72 TEST (std::add_lvalue_reference, int (), int (&)());
73 TEST (std::add_lvalue_reference, int (&)(), int (&)());
74
75 TEST (std::add_lvalue_reference, int (class_t::*), int (class_t::*&));
76 TEST (std::add_lvalue_reference, int (class_t::*)(), int (class_t::*&)());
77}
78
79static void test_add_rvalue_reference ()
80{
81#ifndef _RWSTD_NO_RVALUE_REFERENCE
82
83#else
84 rw_warn (0, 0, __LINE__,
85 "rvalue references are not supported");
86#endif // _RWSTD_NO_RVALUE_REFERENCE
87}
88
89static void test_remove_reference ()
90{
91 TEST(std::remove_reference, int, int);
92 TEST(std::remove_reference, int&, int);
93
94 TEST(std::remove_reference, int const [], int const []);
95 TEST(std::remove_reference, int const (&) [1], int const [1]);
96
97 TEST(std::remove_reference, int const * volatile,
98 int const * volatile);
99 TEST(std::remove_reference, int const * volatile &,
100 int const * volatile);
101
102 TEST (std::remove_reference, int (), int ());
103 TEST (std::remove_reference, int (&)(), int ());
104
105 TEST (std::remove_reference, int (class_t::*&), int (class_t::*));
106 TEST (std::remove_reference, int (class_t::*&)(), int (class_t::*)());
107}
108
109
111static int run_test (int, char*[])
112{
113 test_add_lvalue_reference ();
114 test_add_rvalue_reference ();
115 test_remove_reference ();
116
117 return 0;
118}
119
120
122#else // _RWSTD_NO_EXT_CXX_0X
123
124
126static int run_test (int, char*[])
127{
128 rw_warn (0, 0, __LINE__,
129 "test disabled because _RWSTD_NO_EXT_CXX_0X is defined");
130 return 0;
131}
132
133#endif // !_RWSTD_NO_EXT_CXX_0X
134
135
137int main (int argc, char *argv[])
138{
139 return rw_test (argc, argv, __FILE__,
140 "meta.trans.ref",
141 0 /* no comment */,
142 run_test,
143 0);
144}
#define line
Definition 17.names.cpp:490
void test_trait(int line, const char *trait, const char *typeT, const char *typeU, bool success)
#define TEST(Trait, TypeT, TypeU)
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_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