Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
duck-detector-test.cpp
Go to the documentation of this file.
1 /*
2  DuckDetector(Test) - detecting properties of a type at compile time
3 
4  Copyright (C) Lumiera.org
5  2010, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
29 #include "lib/test/run.hpp"
31 #include "lib/format-cout.hpp"
32 #include "lib/util.hpp"
33 
34 
35 namespace lib {
36 namespace meta{
37 namespace test{
38 
39 
40  namespace { // some test ducks....
41 
42 
43  struct PropperGander
44  {
45  class Core;
46 
47  PropperGander& honk (long,long);
48  };
49 
50 
51  struct Propaganda
52  {
53  void honk(float);
54  };
55 
56 
57  }//(End) with test ducks
58 
59 #define SHOW_CHECK(_EXPR_) cout << STRINGIFY(_EXPR_) << "\t : " << (_EXPR_::value? "Yes":"No") << endl;
60 
61 
62 
63  /*******************************************************************************/
70  class DuckDetector_test : public Test
71  {
72 
73  META_DETECT_NESTED(Core);
74  META_DETECT_MEMBER(honk);
75  META_DETECT_FUNCTION(PropperGander&, honk, (long,long));
76 
77 
78  void
79  run (Arg)
80  {
81  SHOW_CHECK( HasNested_Core<PropperGander> );
82  SHOW_CHECK( HasNested_Core<Propaganda> );
83 
84  SHOW_CHECK( HasMember_honk<PropperGander> );
85  SHOW_CHECK( HasMember_honk<Propaganda> );
86 
87  SHOW_CHECK( HasFunSig_honk<PropperGander> );
88  SHOW_CHECK( HasFunSig_honk<Propaganda> );
89  }
90  };
91 
92 
94  LAUNCHER (DuckDetector_test, "unit meta");
95 
96 
97 
98 }}} // namespace lib::meta::test
Automatically use custom string conversion in C++ stream output.
Definition: run.hpp:49
Implementation namespace for support and library code.
std::vector< string > & Arg
Definition: run.hpp:54
Simple test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
#define SHOW_CHECK(_EXPR_)
LAUNCHER(ConfigFlags_test,"unit common")
Register this test class...
META_DETECT_FUNCTION(PropperGander &, honk,(long, long))
Metaprogramming helpers to check for specific properties of a type in question.