2
3
4
5
8#include <gmock/gmock.h>
9#include <Core/Delegate/DelegateBasic.h>
15
16
22
23
26 std::cout <<
"Hello DelegateFuncTest::Test" << std::endl;
30
31
32
35 std::cout <<
"Hello DelegateFuncTest::Test(float)" << std::endl;
39
40
41
42
45 std::cout <<
"Hello DelegateFuncTest::Test0(int, int)" <<
" " << a <<
" " << b << std::endl;
49
50
53 std::cout <<
"Hello DelegateFuncTest::Test1" << std::endl;
58
59
60
61 template<
typename ...Args>
64 std::cout <<
"Hello DelegateTestT(args...)" << std::endl;
68
69
82
83
89
90
91
97
98
116
117
124 test0.Bind(std::bind((
void(DelegateFuncTest::*)())&DelegateFuncTest::Test, &funcTestClass));
125 test1.Bind(std::bind((
void(DelegateFuncTest::*)(
float))&DelegateFuncTest::Test, &funcTestClass, std::placeholders::_1));
126 test2.Bind(std::bind(&DelegateFuncTest::Test0, &funcTestClass, std::placeholders::_1, std::placeholders::_2));
127 test0.Bind(std::bind(&DelegateFuncTest::Test1));
129 test0.Bind([&]() {
return funcTestClass.Test(); });
130 test1.Bind([&](
float f) {
return funcTestClass.Test(f); });
131 test2.Bind([&](
int a,
int b) {
return funcTestClass.Test0(a, b); });
132 test0.Bind([&]() {
return DelegateFuncTest::Test1(); });
133 test0.Bind([&]() {
return DelegateTestT(); });
135 test1.Bind([](
bool val) {
return val; });
138
139
140 EXPECT_EQ(test0.size(), 5);
141 EXPECT_EQ(test1.size(), 3);
142 EXPECT_EQ(test2.size(), 2);
143 EXPECT_EQ(test2.empty(),
false);
147
148
155 test0.Bind(std::bind((
void(DelegateFuncTest::*)())&DelegateFuncTest::Test, &funcTestClass));
156 test0.Bind(std::bind(&DelegateFuncTest::Test1));
157 test0.Bind([&]() {
return funcTestClass.Test(); });
158 test0.Bind([&]() {
return DelegateFuncTest::Test1(); });
159 test0.Bind([&]() {
return DelegateTestT(); });
161 EXPECT_EQ(test0.size(), 5);
162 EXPECT_EQ(test2.empty(),
true);
164 test0.UnBind(std::bind((
void(DelegateFuncTest::*)()) & DelegateFuncTest::Test, &funcTestClass));
165 test0.UnBind(std::bind(&DelegateFuncTest::Test1));
166 test0.UnBind([&]() {
return funcTestClass.Test(); });
167 test0.UnBind([&]() {
return DelegateFuncTest::Test1(); });
168 test0.UnBind([&]() {
return DelegateTestT(); });
170 EXPECT_EQ(test0.size(), 3);
171 EXPECT_EQ(test2.empty(),
true);
175
176
183 test2.Bind(std::bind(&DelegateFuncTest::Test0, &funcTestClass, std::placeholders::_1, std::placeholders::_2));
184 test2.Broadcast(1, 10);
186 EXPECT_EQ(test2.size(), 1);
187 EXPECT_EQ(test2.empty(),
false);
191
192
200
201
203 test2.Bind(std::bind(&DelegateFuncTest::Test0, &funcTestClass, std::placeholders::_1, std::placeholders::_2));
205 EXPECT_EQ(test2.size(), 1);
206 EXPECT_EQ(test2.empty(),
false);
210
211
213 DelegateTest2 test2c = test2;
215 EXPECT_EQ(test2c.size(), 1);
216 EXPECT_EQ(test2c.empty(),
false);
218 test2c.UnBind(std::bind(&
DelegateFuncTest::Test0, &funcTestClass, std::placeholders::_1, std::placeholders::_2));
220 EXPECT_EQ(test2.size(), 0);
221 EXPECT_EQ(test2.empty(),
true);
#define DELEGATE_ONE_PARAM(name, p0)
Use this macro to instance a Delegate Class. One Parameter Specific.
#define DELEGATE_THREE_PARAM(name, p0, p1, p2)
Use this macro to instance a Delegate Class. Three Parameter Specific.
#define DELEGATE_SIX_PARAM(name, p0, p1, p2, p3, p4, p5)
Use this macro to instance a Delegate Class. Six Parameter Specific.
#define DELEGATE_FIVE_PARAM(name, p0, p1, p2, p3, p4)
Use this macro to instance a Delegate Class. Five Parameter Specific.
#define DELEGATE_NONE_PARAM(name)
Use this macro to instance a Delegate Class. None Parameter Specific.
#define DELEGATE_SEVEN_PARAM(name, p0, p1, p2, p3, p4, p5, p6)
Use this macro to instance a Delegate Class. Seven Parameter Specific.
#define DELEGATE_EIGHT_PARAM(name, p0, p1, p2, p3, p4, p5, p6, p7)
Use this macro to instance a Delegate Class. Eight Parameter Specific.
#define DELEGATE_TWO_PARAM(name, p0, p1)
Use this macro to instance a Delegate Class. Two Parameter Specific.
#define DELEGATE_FOUR_PARAM(name, p0, p1, p2, p3)
Use this macro to instance a Delegate Class. Four Parameter Specific.
#define DELEGATE_NINE_PARAM(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)
Use this macro to instance a Delegate Class. Nine Parameter Specific.
#define SPICESTEST_PROFILE_SCOPE_LINE2(name, line)
#define SPICESTEST_PROFILE_SCOPE(name)
#define SPICESTEST_PROFILE_END_SESSION()
#define SPICESTEST_PROFILE_BEGIN_SESSION(name, filepath)
#define SPICESTEST_PROFILE_SCOPE_LINE(name, line)
#define SPICESTEST_PROFILE_FUNCTION()
void Test0(int a, int b)
Basic Class Function.
void Test(float f)
Basic Override Class Function.
void Test()
Basic Override Class Function.
static void Test1()
Static Class Function.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
void TearDown() override
Testing class TearDown function.
InstrumentationTimer(const char *name)
std::chrono::time_point< std::chrono::steady_clock > m_StartTimepoint
Instrumentor(Instrumentor &&)=delete
static Instrumentor & Get()
void BeginSession(const std::string &name, const std::string &filepath="results.json")
void WriteProfile(const ProfileResult &result)
InstrumentationSession * m_CurrentSession
std::ofstream m_OutputStream
Instrumentor(const Instrumentor &)=delete
void InternalEndSession()
void Test(float f)
Basic Override Class Function.
static void Test1()
Static Class Function.
void Test()
Basic Override Class Function.
void TearDown() override
Testing class TearDown function.
std::vector< scl::directed_acyclic_node > m_Nodes
void SetUp() override
Testing class initialize function.
scl::directed_acyclic_graph m_DAG
The interface is inherited from testing::Test. Registy on Initialize.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
scl::free_list m_FreeList
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
The interface is inherited from testing::Test. Registry on Initialize.
scl::kd_tree< 2 > m_KDTree
Create a KDTree with 2 dimensions.
void TearDown() override
Testing class TearDown function.
void SetUp() override
Testing class initialize function.
The interface is inherited from testing::Test. Registry on Initialize.
scl::linked_unordered_map< int, std::string > c1
scl::linked_unordered_map< float, std::string > c2
scl::linked_unordered_map< std::string, std::string > c0
void SetUp() override
Testing class initialize function.
void TearDown() override
Testing class TearDown function.
The interface is inherited from testing::Test. Registry on Initialize.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
void TearDown() override
Testing class TearDown function.
scl::runtime_memory_block m0
Unit Test for RuntimeMemoryBlock.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
scl::span_list m_SpanList
The interface is inherited from testing::Test. Registry on Initialize.
static void Init()
Init Log.
static void ShutDown()
Shutdown Log.
behave_state_list. wrapper of combing all state behaves.
bool Empty() const
Determine if this list is empty.
void Push(void *obj)
Recycle a object memory to this free list.
void *& Begin()
Get current pointer (no const & reference version).
void *& End()
Get end pointer (no const & reference version).
Free list for memory pool.
The kd_tree with K dimensions container Class. K the number of dimensions. Every node in the tree is ...
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
void build()
Malloc a memory to begin_.
void add_element(const std::string &name, const std::string &type)
Add a element to object_, means a memory block will be occupied with given param type.
runtime_memory_block()=default
Constructor Function.
void * get_addr() const
Get the begin_.
The container is wrapper of a continue memory block. Used in Material::BuildMaterial(),...
Bidirectional cyclic linked list for span.
span * m_Prev
previous span.
Used for manage multiple page memory.
This Class is similar to std::vector, the difference between that is this one allocates memory by mal...
int main(int argc, char **argv)
The Entry of SpicesTest.
constexpr auto CleanupOutputString(const char(&expr)[N], const char(&remove)[K])
TEST_F(free_list_test, PushPop)
Testing scl::free_list::Push/Pop.
TEST_F(runtime_memory_block_test, Initialize)
Testing if initialize successfully.
TEST_F(directed_acyclic_graph_test, Addnode)
Testing if add node successfully.
TEST_F(span_list_test, Initialize)
Testing scl::span_list::Initialize.
TEST_F(linked_unordered_map_test, Initialize)
Testing if initialize successfully.
TEST_F(kd_tree_test, Insert)
Testing if Insert successfully.
void DelegateTestT(Args ...args)
Template Function.
TEST(tuple_test, IterTuple)
Testing std::tuple Helper Function.
TEST_F(Delegate_test, Bind)
Testing if bind successfully.
void IterTuple(Tuple &tuple, Function &&f)
Iter a tuple.
std::chrono::microseconds ElapsedTime
FloatingPointMicroseconds Start