Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
argument-tuple-accept-test.cpp
Go to the documentation of this file.
1/*
2 ArgumentTupleAccept(Test) - verify synthesising a bind(...) function
3
4 Copyright (C)
5 2009, 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"
23#include "lib/meta/function.hpp"
24#include "lib/format-cout.hpp"
25
26#include <functional>
27#include <tuple>
28
29
30namespace steam {
31namespace control {
32namespace test {
33
36
38 using std::function;
39 using lib::meta::_Fun;
40 using lib::meta::Tuple;
41
42
43
44
45
46
47 namespace { // build a test dummy class....
48
49 template<typename SIG>
50 struct _Tup
51 {
54 using Ty = Tuple<Args>;
55 };
56
57
58 template<typename SIG>
60 : public AcceptArgumentBinding< SIG // to derive the desired signature
61 , TestClass<SIG> // the target class providing the implementation
62 , typename _Tup<SIG>::Ty // base class to inherit from
63 >
64 {
67
68 public:
69
71 bindArg (ATuple const& tuple)
72 {
73 static_cast<ATuple&> (*this) = tuple;
74 return RetType();
75 }
76 };
77
78
79 } // test-helper implementation
80
81
82
83
84
85
86 /*********************************************************/
92 class ArgumentTupleAccept_test : public Test
93 {
94
95 virtual void
96 run (Arg)
97 {
98 TestClass<void()> testVoid;
99 TestClass<int(TimeVar,int)> testTime;
100
101 testVoid.bind();
102 testTime.bind(randTime(),23);
103
104 cout << showSizeof(testVoid) << endl;
105 cout << showSizeof(testTime) << endl;
106
108 CHECK (23 == std::get<1> (testTime));
109 }
110
111 };
112
113
114
116 LAUNCHER (ArgumentTupleAccept_test, "unit controller");
117
118
119}}} // namespace steam::control::test
Mixin-templates providing arbitrary function call operators and argument binding functions.
a mutable time value, behaving like a plain number, allowing copy and re-accessing
Helper Template for Steam-Layer control::Command : mix in a bind(...) function.
Automatically use custom string conversion in C++ stream output.
Metaprogramming tools for detecting and transforming function types.
BuildTupleType< TYPES >::Type Tuple
Build a std::tuple from types given as type sequence.
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
string showSizeof(size_t siz, string name)
for printing sizeof().
lib::time::Time randTime()
create a random but not insane Time value between 1s ... 10min + 500ms
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Trait template for uniform access to function signature types.
Definition function.hpp:144
A collection of frequently used helper functions to support unit testing.
Metaprogramming with tuples-of-types and the std::tuple record.