]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | // (C) Copyright Edward Diener 2011-2015 | |
3 | // Use, modification and distribution are subject to the Boost Software License, | |
4 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt). | |
6 | ||
7 | #include <boost/vmd/is_empty.hpp> | |
8 | #include <boost/preprocessor/facilities/empty.hpp> | |
9 | #include <boost/detail/lightweight_test.hpp> | |
10 | ||
11 | int main() | |
12 | { | |
13 | ||
14 | #if BOOST_PP_VARIADICS | |
15 | ||
16 | #define DATA | |
17 | #define OBJECT OBJECT2 | |
18 | #define OBJECT2 | |
19 | #define FUNC(x) FUNC2(x) | |
20 | #define FUNC2(x) | |
21 | ||
22 | BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_EMPTY())); | |
23 | BOOST_TEST(BOOST_VMD_IS_EMPTY(DATA BOOST_PP_EMPTY())); | |
24 | BOOST_TEST(!BOOST_VMD_IS_EMPTY(x BOOST_PP_EMPTY())); | |
25 | BOOST_TEST(BOOST_VMD_IS_EMPTY(OBJECT BOOST_PP_EMPTY())); | |
26 | BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY())); | |
27 | ||
28 | #define FUNC_GEN() () | |
29 | #define FUNC_GEN2(x) () | |
30 | #define FUNC_GEN3() anything | |
31 | #define FUNC_GEN4(x) anything | |
32 | ||
33 | #if BOOST_VMD_MSVC | |
34 | ||
35 | #define FUNC_GEN5(x,y) () | |
36 | #define FUNC_GEN6(x,y) anything | |
37 | ||
38 | /* This shows that VC++ does not work correctly in these cases. */ | |
39 | ||
40 | BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC_GEN)); /* This produces the wrong result */ | |
41 | BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC_GEN2)); /* This produces the wrong result */ | |
42 | ||
43 | BOOST_TEST(BOOST_VMD_IS_EMPTY(FUNC_GEN5)); /* This should produce a compiler error but does not and produces the incorrect result */ | |
44 | BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN6)); /* This should produce a compiler error but does not */ | |
45 | ||
46 | #else | |
47 | ||
48 | #define FUNC_GEN5() (&) | |
49 | #define FUNC_GEN6(x) (y) | |
50 | #define FUNC_GEN7() (y,z) | |
51 | ||
52 | BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN)); | |
53 | BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN2)); | |
54 | ||
55 | BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN5)); | |
56 | BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN6)); | |
57 | BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN7)); | |
58 | ||
59 | #endif /* BOOST_VMD_MSVC */ | |
60 | ||
61 | BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN3)); | |
62 | BOOST_TEST(!BOOST_VMD_IS_EMPTY(FUNC_GEN4)); | |
63 | ||
64 | #else | |
65 | ||
66 | BOOST_ERROR("No variadic macro support"); | |
67 | ||
68 | #endif /* BOOST_PP_VARIADICS */ | |
69 | ||
70 | return boost::report_errors(); | |
71 | ||
72 | } |