Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
duck-detector-extension-test.cpp
Go to the documentation of this file.
1/*
2 DuckDetectorExtension(Test) - detecting support for extension points at compile time
3
4 Copyright (C)
5 2017, 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
19#include "lib/test/run.hpp"
21#include "lib/util.hpp"
22
23#include <string>
24
25
26namespace lib {
27namespace meta{
28namespace test{
29
30 using std::string;
31
32
33 namespace { // test types and definitions to explore....
34
35 void
36 fun (long)
37 { }
38
39 int
40 fun (string, long)
41 {
42 return 12;
43 }
44
45 void
46 fun ()
47 { }
48
49
50 class Cheesy
51 {
52 public:
53 double funny (char, char, string);
54 void funky() const;
55 short fuzzy (float, float);
57 double fully;
58 };
59
60 class Fishy
61 {
64
66 friend void fun (Fishy&);
67 };
68
69
70 }//(End) test definitions
71
72
73
74
75 /***********************************************************************************/
90 class DuckDetectorExtension_test : public Test
91 {
92
95
96 META_DETECT_FUNCTION (double, funny, (char, char, string));
97 META_DETECT_FUNCTION (llong, fuzzy, (void));
109
110
111 void
117
118
134 void
160
161
171 void
173 {
174 CHECK ( HasFunSig_funny<Cheesy> ::value ); // explicit function signature detected
175 CHECK ( HasFunSig_funny<Cheesy const> ::value ); // const qualifier is irrelevant
176 CHECK ( not HasFunSig_funny<Cheesy const&> ::value ); // but reference does not work, obviously
177
178 CHECK ( HasFunSig_fuzzy<Cheesy> ::value ); // explicit function signature detected, overload is irrelevant
179
180 CHECK ( HasFunName_funny<Cheesy> ::value ); // function name detected (arguments irrelevant)
181 CHECK ( HasFunName_funky<Cheesy> ::value ); // detected irrespective of const modifier
182 CHECK ( not HasFunName_fuzzy<Cheesy> ::value ); // function name fuzzy *not* detected due to overload ambiguity
183 CHECK ( not HasFunName_fully<Cheesy> ::value ); // name fully is a member, not a function
184
185 CHECK ( HasMember_funny<Cheesy> ::value ); // 'funny' is not only a function, it is also a member
187 CHECK ( not HasMember_fuzzy<Cheesy> ::value ); // WARNING: member 'fuzzy' *not* detected due to overload ambiguity
188 CHECK ( HasMember_fully<Cheesy> ::value ); // 'fully' is not a function, but it is detected as member here
189
190 CHECK ( not HasArglessFun_funny<Cheesy> ::value ); // there is no argument less function 'funny' (it takes arguments)
191 CHECK ( HasArglessFun_funky<Cheesy> ::value ); // but an argument-less 'funky'
192 CHECK ( HasArglessFun_fuzzy<Cheesy> ::value ); // and one of the 'fuzzy' overloads also takes no arguments
193
194 CHECK ( not HasFunSig_fuzzy<Fishy> ::value ); // Fishy::fuzzy() is private and can thus never be detected
195 CHECK ( not HasFunSig_funny<Fishy> ::value ); // and no fun with Fishy beyond that...
208 }
209 };
210
211
214
215
216
217}}} // namespace lib::meta::test
META_DETECT_FUNCTION(double, funny,(char, char, string))
Metaprogramming helpers to check for specific properties of a type in question.
long long int llong
Definition integral.hpp:32
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
Implementation namespace for support and library code.
Test runner and basic definitions for tests.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...