2
3
4
5
8#include <gmock/gmock.h>
9#include <Core/Container/FreeList.h>
15
16
17
23
24
25
29
30
31
38
39
47 std::tuple<
int,
void* (*)(
int)> d { 1,
nullptr };
49 EXPECT_EQ(m_FreeList.Empty(),
true);
50 EXPECT_EQ(m_FreeList.ApplyforNBlocks(), 1);
51 EXPECT_EQ(m_FreeList.Size(), 0);
52 EXPECT_EQ(m_FreeList.Begin(),
nullptr);
53 EXPECT_EQ(m_FreeList.End(),
nullptr);
61 EXPECT_EQ(m_FreeList.Empty(),
false);
62 EXPECT_EQ(m_FreeList.ApplyforNBlocks(), 1);
63 EXPECT_EQ(m_FreeList.Size(), 4);
64 EXPECT_EQ(m_FreeList.End(), &a);
66 const void* p = m_FreeList.Begin();
69 const void* p1 = *(
void**)p;
72 const void* p2 = *(
void**)p1;
75 const void* p3 = *(
void**)p2;
78 const void* p4 = *(
void**)p3;
79 EXPECT_EQ(p4,
nullptr);
83 EXPECT_EQ(m_FreeList.Pop(), &d);
84 EXPECT_EQ(m_FreeList.Pop(), &c);
85 EXPECT_EQ(m_FreeList.Pop(), &b);
86 EXPECT_EQ(m_FreeList.Pop(), &a);
88 EXPECT_EQ(m_FreeList.Empty(),
true);
89 EXPECT_EQ(m_FreeList.ApplyforNBlocks(), 1);
90 EXPECT_EQ(m_FreeList.Size(), 0);
91 EXPECT_EQ(m_FreeList.Begin(),
nullptr);
92 EXPECT_EQ(m_FreeList.End(),
nullptr);
97
98
105 std::array<
int, 2> a;
108 std::tuple<
int,
void* (*)(
int)> d { 1,
nullptr };
117 m_FreeList.PushRange(list.Begin(), list.End(), list.Size());
119 EXPECT_EQ(m_FreeList.Empty(),
false);
120 EXPECT_EQ(m_FreeList.ApplyforNBlocks(), 1);
121 EXPECT_EQ(m_FreeList.Size(), 4);
122 EXPECT_EQ(m_FreeList.End(), &a);
124 const void* p = m_FreeList.Begin();
127 const void* p1 = *(
void**)p;
130 const void* p2 = *(
void**)p1;
133 const void* p3 = *(
void**)p2;
136 const void* p4 = *(
void**)p3;
137 EXPECT_EQ(p4,
nullptr);
142 m_FreeList.PopRange(list2.Begin(), list2.End(), list.Size());
145 EXPECT_EQ(m_FreeList.Empty(),
false);
146 EXPECT_EQ(m_FreeList.ApplyforNBlocks(), 1);
147 EXPECT_EQ(m_FreeList.Size(), 2);
148 EXPECT_EQ(m_FreeList.End(), &a);
150 const void* p = m_FreeList.Begin();
153 const void* p1 = *(
void**)p;
156 const void* p2 = *(
void**)p1;
157 EXPECT_EQ(p2,
nullptr);
162 EXPECT_EQ(list2.ApplyforNBlocks(), 1);
163 EXPECT_EQ(list2.Size(), 0);
164 EXPECT_EQ(list2
.End(), &c);
169 const void* p1 = *(
void**)p;
172 const void* p2 = *(
void**)p1;
173 EXPECT_EQ(p2,
nullptr);
#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()
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.
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(),...
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(linked_unordered_map_test, Initialize)
Testing if initialize successfully.
TEST_F(kd_tree_test, Insert)
Testing if Insert successfully.
TEST(tuple_test, IterTuple)
Testing std::tuple Helper Function.
void IterTuple(Tuple &tuple, Function &&f)
Iter a tuple.
std::chrono::microseconds ElapsedTime
FloatingPointMicroseconds Start