Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
20.meta.trans.arr.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
40void test_trait (int line, const char* trait,
41 const char* typeT, const char* typeU,
42 bool success)
43{
44 rw_assert (success, 0, line,
45 "%s<%s>::type is %{?}exactly%{:}not%{;} %s",
46 trait, typeT, success, typeU);
47}
48
49#define TEST(Trait,TypeT,TypeU) \
50 test_trait(__LINE__, #Trait, #TypeT, #TypeU, \
51 std::is_same<Trait<TypeT>::type, TypeU>::value)
52
53
55static void test_remove_extent ()
56{
57 TEST (std::remove_extent, int, int);
58 TEST (std::remove_extent, int[], int);
59 TEST (std::remove_extent, int[5], int);
60 TEST (std::remove_extent, int[][5], int[5]);
61 TEST (std::remove_extent, int[5][5], int[5]);
62
63 TEST (std::remove_extent, void, void);
64 TEST (std::remove_extent, void*, void*);
65
66 TEST (std::remove_extent, long (*)[1], long (*)[1]);
67
68 TEST (std::remove_extent, long (), long ());
69 TEST (std::remove_extent, long (*)(), long (*)());
70 TEST (std::remove_extent, long (&)(), long (&)());
71}
72
73static void test_remove_all_extents ()
74{
75 TEST (std::remove_all_extents, int, int);
76 TEST (std::remove_all_extents, int[], int);
77 TEST (std::remove_all_extents, int[5], int);
78 TEST (std::remove_all_extents, int[][5], int);
79 TEST (std::remove_all_extents, int[5][5], int);
80
81 TEST (std::remove_all_extents, void, void);
82 TEST (std::remove_all_extents, void*, void*);
83
84 TEST (std::remove_all_extents, long (*)[1], long (*)[1]);
85
86 TEST (std::remove_all_extents, long (), long ());
87 TEST (std::remove_all_extents, long (*)(), long (*)());
88 TEST (std::remove_all_extents, long (&)(), long (&)());
89}
90
91
93static int run_test (int, char*[])
94{
95 test_remove_extent ();
96 test_remove_all_extents ();
97
98 return 0;
99}
100
101
103#else // _RWSTD_NO_EXT_CXX_0X
104
105
107static int run_test (int, char*[])
108{
109 rw_warn (0, 0, __LINE__,
110 "test disabled because _RWSTD_NO_EXT_CXX_0X is defined");
111 return 0;
112}
113
114#endif // !_RWSTD_NO_EXT_CXX_0X
115
116
118int main (int argc, char *argv[])
119{
120 return rw_test (argc, argv, __FILE__,
121 "meta.trans.arr",
122 0 /* no comment */,
123 run_test,
124 0);
125}
#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