-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathTest_Base.hpp
164 lines (130 loc) · 4.41 KB
/
Test_Base.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#pragma once
#include <iostream>
#include <functional>
#include <random>
#include "../nano_signal_slot.hpp"
#include "../nano_mutex.hpp"
namespace Nano_Tests
{
namespace
{
static void anonymous_output(const char* fn, const char* sl, std::size_t ln)
{
std::cout << fn << " LINE: " << __LINE__ << " Test: " << sl << " LINE: " << ln << std::endl;
}
}
using Rng = std::minstd_rand;
using Observer = Nano::Observer<>;
using Signal_One = Nano::Signal<void(const char*)>;
using Signal_Two = Nano::Signal<void(const char*, std::size_t)>;
using Observer_ST = Nano::Observer<Nano::ST_Policy>;
using Signal_Rng_ST = Nano::Signal<void(Rng&), Nano::ST_Policy>;
using Observer_STS = Nano::Observer<Nano::ST_Policy_Safe>;
using Signal_Rng_STS = Nano::Signal<void(Rng&), Nano::ST_Policy_Safe>;
using Observer_TS = Nano::Observer<Nano::TS_Policy<>>;
using Signal_Rng_TS = Nano::Signal<void(Rng&), Nano::TS_Policy<>>;
using Observer_TSS = Nano::Observer<Nano::TS_Policy_Safe<>>;
using Signal_Rng_TSS = Nano::Signal<void(Rng&), Nano::TS_Policy_Safe<>>;
using Delegate_One = std::function<void(const char*)>;
using Delegate_Two = std::function<void(const char*, std::size_t)>;
//--------------------------------------------------------------------------
class Foo : public Observer
{
public:
void slot_member_signature_one(const char* sl)
{
anonymous_output(__FUNCTION__, sl, __LINE__);
}
void slot_member_signature_two(const char* sl, std::size_t ln)
{
anonymous_output(__FUNCTION__, sl, ln);
}
void slot_const_member_signature_one(const char* sl) const
{
anonymous_output(__FUNCTION__, sl, __LINE__);
}
void slot_const_member_signature_two(const char* sl, std::size_t ln) const
{
anonymous_output(__FUNCTION__, sl, ln);
}
void slot_overloaded_member(const char* sl)
{
anonymous_output(__FUNCTION__, sl, __LINE__);
}
void slot_overloaded_member(const char* sl, std::size_t ln)
{
anonymous_output(__FUNCTION__, sl, ln);
}
static void slot_static_member_function(const char* sl)
{
anonymous_output(__FUNCTION__, sl, __LINE__);
}
static void slot_static_member_function(const char* sl, std::size_t ln)
{
anonymous_output(__FUNCTION__, sl, ln);
}
virtual void slot_virtual_member_function(const char* sl)
{
anonymous_output(__FUNCTION__, sl, __LINE__);
}
virtual void slot_virtual_member_function(const char* sl, std::size_t ln)
{
anonymous_output(__FUNCTION__, sl, ln);
}
};
//--------------------------------------------------------------------------
class Bar : public Foo
{
public:
void slot_virtual_member_function(const char* sl) override
{
anonymous_output(__FUNCTION__, sl, __LINE__);
}
void slot_virtual_member_function(const char* sl, std::size_t ln) override
{
anonymous_output(__FUNCTION__, sl, ln);
}
};
//--------------------------------------------------------------------------
static void slot_static_free_function(const char* sl)
{
anonymous_output(__FUNCTION__, sl, __LINE__);
}
static void slot_static_free_function(const char* sl, std::size_t ln)
{
anonymous_output(__FUNCTION__, sl, ln);
}
//--------------------------------------------------------------------------
template <typename T>
class Moo : public T
{
public:
void slot_next_random(Rng& rng)
{
rng.discard(1);
}
static void slot_static_next_random(Rng& rng)
{
rng.discard(1);
}
};
static void slot_next_random_free_function(Rng& rng)
{
rng.discard(1);
}
//--------------------------------------------------------------------------
class Copy_Count
{
public:
std::size_t count = 0;
Copy_Count() = default;
Copy_Count(Copy_Count const& other) : count(other.count + 1)
{
}
Copy_Count& operator= (Copy_Count const& other)
{
count = other.count + 1;
return *this;
}
};
}