Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
test-helper-variadic-test.cpp
Go to the documentation of this file.
1/*
2 TestHelperVariadic(Test) - verify variadic template diagnostics helper
3
4 Copyright (C)
5 2014, 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
22
23#include <iostream>
24#include <utility>
25#include <string>
26#include <cmath>
27
28using std::string;
29using std::cout;
30
31
32namespace lib {
33namespace test{
34namespace test{
35
36 namespace { // test fixture...
37
39 {
40 public:
42 Interface(Interface const& o) { cout << "COPY.CT from "<<&o<<" !!!\n"; }
43 Interface(Interface const&& o) { cout << "MOVE.CT from "<<&o<<" !!!\n"; }
44
45 Interface& operator= (Interface const& o) { cout << "COPY= from "<<&o<<" !!!\n"; return *this; }
46 Interface& operator= (Interface const&& o) { cout << "MOVE= from "<<&o<<" !!!\n"; return *this; }
47
48 virtual ~Interface() { }
49 };
50
51 class Impl
52 : public Interface
53 {
54 string s_;
55
56 public:
57 Impl(string ss ="ZOMG") : s_(ss) { }
58 };
59
60
61 inline double
63 {
64 return atan2(0,-0.0);
65 }
66
67
68 }//(End) test fixture
69
70
71
72
73
74
75 /****************************************************************************/
90 class TestHelperVariadic_test : public Test
91 {
92
93 virtual void
94 run (Arg)
95 {
96 double d = makeRvalue();
97 double const& cr = d;
98
99 Impl obj;
100 Interface const& ref = obj;
101
102 cout << "--no-arg--\n" << showVariadicTypes() <<"\n";
103 cout << "--reference--\n" << showVariadicTypes(d) <<"\n";
104 cout << "--value--\n" << showVariadicTypes(makeRvalue()) <<"\n";
105
106 forwardFunction("two values", "foo", 42L); // displayed as char [4] const&, long &&
107 forwardFunction("references", d,cr,std::move(d)); // displayed as double&, double const&, double &&
108
109 forwardFunction("baseclass", ref); // displayed as Interface const&
110 }
111
112
116 template<typename... ARGS>
117 void
118 forwardFunction (string id, ARGS&&... args)
119 {
120 cout << "--"<<id<<"--\n"
121 << showVariadicTypes (std::forward<ARGS>(args)...)
122 << "\n"
123 ;
124 }
125
126 };
127
128
131
132
133}}} // namespace lib::test::test
Target object to be instantiated as Singleton Allocates a variable amount of additional heap memory a...
void forwardFunction(string id, ARGS &&... args)
this dummy simulates a typical variadic call which takes all arguments as '&&' for the purpose of "pe...
string showVariadicTypes()
helper for investigating a variadic argument pack
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
A collection of frequently used helper functions to support unit testing.