Lumiera  0.pre.03
»edit your freedom«
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)
5  2010, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
20 #include "lib/test/run.hpp"
22 #include "lib/format-cout.hpp"
23 #include "lib/util.hpp"
24 
25 
26 namespace lib {
27 namespace meta{
28 namespace test{
29 
30 
31  namespace { // some test ducks....
32 
33 
35  {
36  class Core;
37 
38  PropperGander& honk (long,long);
39  };
40 
41 
42  struct Propaganda
43  {
44  void honk(float);
45  };
46 
47 
48  }//(End) with test ducks
49 
50 #define SHOW_CHECK(_EXPR_) cout << STRINGIFY(_EXPR_) << "\t : " << (_EXPR_::value? "Yes":"No") << endl;
51 
52 
53 
54  /*******************************************************************************/
61  class DuckDetector_test : public Test
62  {
63 
64  META_DETECT_NESTED(Core);
65  META_DETECT_MEMBER(honk);
66  META_DETECT_FUNCTION(PropperGander&, honk, (long,long));
67 
68 
69  void
70  run (Arg)
71  {
72  SHOW_CHECK( HasNested_Core<PropperGander> );
73  SHOW_CHECK( HasNested_Core<Propaganda> );
74 
75  SHOW_CHECK( HasMember_honk<PropperGander> );
76  SHOW_CHECK( HasMember_honk<Propaganda> );
77 
78  SHOW_CHECK( HasFunSig_honk<PropperGander> );
79  SHOW_CHECK( HasFunSig_honk<Propaganda> );
80  }
81  };
82 
83 
85  LAUNCHER (DuckDetector_test, "unit meta");
86 
87 
88 
89 }}} // namespace lib::meta::test
Automatically use custom string conversion in C++ stream output.
Definition: run.hpp:40
#define META_DETECT_MEMBER(_NAME_)
Detector for a nested member (field or function).
#define META_DETECT_FUNCTION(_RET_TYPE_, _FUN_NAME_, _ARGS_)
Detector for a specific member function.
Implementation namespace for support and library code.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
#define META_DETECT_NESTED(_TYPE_)
Detector for a nested type.
Metaprogramming helpers to check for specific properties of a type in question.