diff --git a/containers_cpp/test/blocking_container_test-inl.h b/containers_cpp/test/blocking_push_and_pop_container_test-inl.h similarity index 94% rename from containers_cpp/test/blocking_container_test-inl.h rename to containers_cpp/test/blocking_push_and_pop_container_test-inl.h index be94a3e..8d7205d 100755 --- a/containers_cpp/test/blocking_container_test-inl.h +++ b/containers_cpp/test/blocking_push_and_pop_container_test-inl.h @@ -40,7 +40,7 @@ n_threads(static_cast n_iterations(200), n_container_elements_per_thread(100), n_container_elements(n_container_elements_per_thread*n_threads), - container(){ + container() { CreateUnit("BlockingContainerTestThreadsPushAndPopToGlobalBlockingContainer"). Pre(&BlockingContainerTest::BlockingContainerTest1_Pre, this). Add(&BlockingContainerTest::BlockingContainerTest1_ThreadMethod, this, @@ -80,7 +80,8 @@ void BlockingContainerTest::BlockingContainerTest1_Post() { PT_ASSERT(produced.size() == expected_container_elements.size()); - std::sort(expected_container_elements.begin(), expected_container_elements.end()); + std::sort(expected_container_elements.begin(), + expected_container_elements.end()); std::sort(produced.begin(), produced.end()); for (unsigned int i = 0; @@ -114,8 +115,8 @@ void BlockingContainerTest::BlockingContainerTest1_ThreadMethod() { my_elements.push_back(return_elem); } } -} // namespace test -} // namespace containers -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb #endif // CONTAINERS_CPP_TEST_BLOCKING_CONTAINER_TEST_INL_H_ diff --git a/containers_cpp/test/blocking_container_test.h b/containers_cpp/test/blocking_push_and_pop_container_test.h similarity index 92% rename from containers_cpp/test/blocking_container_test.h rename to containers_cpp/test/blocking_push_and_pop_container_test.h index 624bc62..a4f02ed 100755 --- a/containers_cpp/test/blocking_container_test.h +++ b/containers_cpp/test/blocking_push_and_pop_container_test.h @@ -26,9 +26,9 @@ #ifndef CONTAINERS_CPP_TEST_BLOCKING_CONTAINER_TEST_H_ #define CONTAINERS_CPP_TEST_BLOCKING_CONTAINER_TEST_H_ +#include #include #include -#include namespace embb { namespace containers { @@ -56,12 +56,11 @@ class BlockingContainerTest : public partest::TestCase { void BlockingContainerTest1_Post(); void BlockingContainerTest1_ThreadMethod(); - }; -} // namespace test -} // namespace containers -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb -#include "./blocking_container_test-inl.h" +#include "./blocking_push_and_pop_container_test-inl.h" #endif // CONTAINERS_CPP_TEST_BLOCKING_CONTAINER_TEST_H_ diff --git a/containers_cpp/test/blocking_queue_test-inl.h b/containers_cpp/test/blocking_queue_test-inl.h index 1dbccd5..26b6cc1 100755 --- a/containers_cpp/test/blocking_queue_test-inl.h +++ b/containers_cpp/test/blocking_queue_test-inl.h @@ -35,17 +35,17 @@ namespace containers { namespace test { template -void BlockingQueueTest::SpecializedPush(const int& element){ +void BlockingQueueTest::SpecializedPush(const int& element) { container.Enqueue(element); } template -void BlockingQueueTest::SpecializedPop(int& element){ +void BlockingQueueTest::SpecializedPop(int& element) { container.Dequeue(element); } -} // namespace test -} // namespace containers -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb #endif // CONTAINERS_CPP_TEST_BLOCKING_QUEUE_TEST_INL_H_ diff --git a/containers_cpp/test/blocking_queue_test.h b/containers_cpp/test/blocking_queue_test.h index 6bc773f..fe6c316 100755 --- a/containers_cpp/test/blocking_queue_test.h +++ b/containers_cpp/test/blocking_queue_test.h @@ -26,24 +26,25 @@ #ifndef CONTAINERS_CPP_TEST_BLOCKING_QUEUE_TEST_H_ #define CONTAINERS_CPP_TEST_BLOCKING_QUEUE_TEST_H_ -#include #include +#include <./blocking_push_and_pop_container_test.h> #include -#include <./blocking_container_test.h> + +#include namespace embb { namespace containers { namespace test { template class BlockingQueueTest : public BlockingContainerTest { - protected: - virtual void SpecializedPush(const int& element); + private: + void SpecializedPush(const int& element); - virtual void SpecializedPop(int& element); + void SpecializedPop(int& element); }; -} // namespace test -} // namespace containers -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb #include "./blocking_queue_test-inl.h" diff --git a/containers_cpp/test/blocking_stack_test-inl.h b/containers_cpp/test/blocking_stack_test-inl.h index c6ab0a3..71a969e 100755 --- a/containers_cpp/test/blocking_stack_test-inl.h +++ b/containers_cpp/test/blocking_stack_test-inl.h @@ -44,9 +44,8 @@ void BlockingStackTest::SpecializedPop(int& element) { container.Pop(element); } - -} // namespace test -} // namespace containers -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb #endif // CONTAINERS_CPP_TEST_BLOCKING_STACK_TEST_INL_H_ diff --git a/containers_cpp/test/blocking_stack_test.h b/containers_cpp/test/blocking_stack_test.h index 3eb140d..a2ce8a8 100755 --- a/containers_cpp/test/blocking_stack_test.h +++ b/containers_cpp/test/blocking_stack_test.h @@ -26,24 +26,25 @@ #ifndef CONTAINERS_CPP_TEST_BLOCKING_STACK_TEST_H_ #define CONTAINERS_CPP_TEST_BLOCKING_STACK_TEST_H_ -#include #include #include -#include <./blocking_container_test.h> +#include <./blocking_push_and_pop_container_test.h> + +#include namespace embb { namespace containers { namespace test { template class BlockingStackTest : public BlockingContainerTest { - protected: - virtual void SpecializedPush(const int& element); + private: + void SpecializedPush(const int& element); - virtual void SpecializedPop(int& element); + void SpecializedPop(int& element); }; -} // namespace test -} // namespace stacks -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb #include "./blocking_stack_test-inl.h" diff --git a/containers_cpp/test/main.cc b/containers_cpp/test/main.cc index 0d45b03..24408d2 100644 --- a/containers_cpp/test/main.cc +++ b/containers_cpp/test/main.cc @@ -48,7 +48,7 @@ #include "./hazard_pointer_test.h" #include "./object_pool_test.h" #include "./set_test.h" -#include "./blocking_map_test.h" +#include "./map_test.h" #define COMMA , @@ -76,7 +76,6 @@ using embb::containers::test::HazardPointerTest2; using embb::containers::test::MapTest; PT_MAIN("Data Structures C++") { - unsigned int max_threads = static_cast( 2 * partest::TestSuite::GetDefaultNumThreads()); embb_thread_set_max_count(max_threads); @@ -96,5 +95,4 @@ PT_MAIN("Data Structures C++") { PT_RUN(ObjectPoolTest< LockFreeTreeValuePool >); PT_RUN(ObjectPoolTest< WaitFreeArrayValuePool >); PT_EXPECT(embb_get_bytes_allocated() == 0); - } diff --git a/containers_cpp/test/blocking_map_test-inl.h b/containers_cpp/test/map_test-inl.h similarity index 89% rename from containers_cpp/test/blocking_map_test-inl.h rename to containers_cpp/test/map_test-inl.h index 1dc8d94..1ce5d64 100755 --- a/containers_cpp/test/blocking_map_test-inl.h +++ b/containers_cpp/test/map_test-inl.h @@ -27,9 +27,11 @@ #ifndef CONTAINERS_CPP_TEST_MAP_TEST_INL_H_ #define CONTAINERS_CPP_TEST_MAP_TEST_INL_H_ +#include + namespace embb { - namespace containers { - namespace test { +namespace containers { +namespace test { template MapTest::MapTest() : @@ -47,7 +49,6 @@ MapTest::MapTest() : static_cast(n_threads), static_cast(n_iterations)). Post(&MapTest::MapTest1_Post, this); - } template @@ -68,7 +69,6 @@ void MapTest::MapTest1_Pre() { thread_local_vectors_value[i].push_back(insert_element * 2); map_contain_vector[static_cast(insert_element)] = false; } - } } @@ -103,24 +103,24 @@ void MapTest::MapTest1_ThreadMethod() { int value = my_values[static_cast(random_number)]; if (inserting) { - PT_ASSERT(map.Insert(key, value) != map_contain_vector[static_cast(key)]); + PT_ASSERT(map.Insert(key, value) != + map_contain_vector[static_cast(key)]); map_contain_vector[static_cast(key)] = true; - } - else { - PT_ASSERT(map.Erase(key) == map_contain_vector[static_cast(key)]); + } else { + PT_ASSERT(map.Erase(key) == + map_contain_vector[static_cast(key)]); map_contain_vector[static_cast(key)] = false; } } - } -} // namespace test -} // namespace containers -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb -#endif // CONTAINERS_CPP_TEST_MAP_TEST_INL_H_ \ No newline at end of file +#endif // CONTAINERS_CPP_TEST_MAP_TEST_INL_H_ diff --git a/containers_cpp/test/blocking_map_test.h b/containers_cpp/test/map_test.h similarity index 91% rename from containers_cpp/test/blocking_map_test.h rename to containers_cpp/test/map_test.h index d43f3c2..8bcf095 100755 --- a/containers_cpp/test/blocking_map_test.h +++ b/containers_cpp/test/map_test.h @@ -27,11 +27,12 @@ #ifndef CONTAINERS_CPP_TEST_MAP_TEST_H_ #define CONTAINERS_CPP_TEST_MAP_TEST_H_ -#include #include #include #include +#include + namespace embb { namespace containers { namespace test { @@ -55,12 +56,11 @@ class MapTest : public partest::TestCase { void MapTest1_Post(); void MapTest1_ThreadMethod(); - }; -} // namespace test -} // namespace containers -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb -#include "./blocking_map_test-inl.h" +#include "./map_test-inl.h" -#endif \ No newline at end of file +#endif // CONTAINERS_CPP_TEST_MAP_TEST_H_ diff --git a/containers_cpp/test/set_test-inl.h b/containers_cpp/test/set_test-inl.h index 129b059..d99896e 100755 --- a/containers_cpp/test/set_test-inl.h +++ b/containers_cpp/test/set_test-inl.h @@ -28,10 +28,11 @@ #ifndef CONTAINERS_CPP_TEST_SET_TEST_INL_H_ #define CONTAINERS_CPP_TEST_SET_TEST_INL_H_ -#include -#include #include +#include +#include + namespace embb { namespace containers { namespace test { @@ -55,7 +56,7 @@ SetTest::SetTest() : } template -void SetTest::SetTest1_Pre(){ +void SetTest::SetTest1_Pre() { embb_internal_thread_index_reset(); thread_local_vectors = new std::vector[static_cast(n_threads)]; @@ -72,7 +73,7 @@ void SetTest::SetTest1_Pre(){ } template -void SetTest::SetTest1_Post(){ +void SetTest::SetTest1_Post() { unsigned int set_elements = set_contain_vector.size(); for (unsigned int i = 0; i < set_elements; i++) { PT_ASSERT(set_contain_vector[i] == set.Contains(static_cast(i))); @@ -87,7 +88,7 @@ void SetTest::SetTest1_ThreadMethod() { int return_val = embb_internal_thread_index(&thread_index); PT_ASSERT(EMBB_SUCCESS == return_val); - + srand(time(NULL)); std::vector& my_elements = thread_local_vectors[thread_index]; @@ -99,19 +100,20 @@ void SetTest::SetTest1_ThreadMethod() { int element = my_elements[static_cast(random_number)]; if (inserting) { - PT_ASSERT(set.Insert(element) != set_contain_vector[static_cast(element)]); + PT_ASSERT(set.Insert(element) != + set_contain_vector[static_cast(element)]); set_contain_vector[static_cast(element)] = true; - } - else { - PT_ASSERT(set.Erase(element) == set_contain_vector[static_cast(element)]); + } else { + PT_ASSERT(set.Erase(element) == + set_contain_vector[static_cast(element)]); set_contain_vector[static_cast(element)] = false; } } } - -} // namespace test -} // namespace containers -} // namespace embb -#endif // CONTAINERS_CPP_TEST_SET_TEST_INL_H_ \ No newline at end of file +} // namespace test +} // namespace containers +} // namespace embb + +#endif // CONTAINERS_CPP_TEST_SET_TEST_INL_H_ diff --git a/containers_cpp/test/set_test.h b/containers_cpp/test/set_test.h index 3cc3a5f..3631043 100755 --- a/containers_cpp/test/set_test.h +++ b/containers_cpp/test/set_test.h @@ -26,16 +26,17 @@ #ifndef CONTAINERS_CPP_TEST_SET_TEST_H_ #define CONTAINERS_CPP_TEST_SET_TEST_H_ -#include #include #include +#include + namespace embb { namespace containers { namespace test { template class SetTest : public partest::TestCase { -private: + private: int n_threads; int n_iterations; int n_operations_per_iteration; @@ -44,7 +45,7 @@ private: std::vector* thread_local_vectors; std::vector set_contain_vector; -public: + public: SetTest(); void SetTest1_Pre(); @@ -53,10 +54,10 @@ public: void SetTest1_ThreadMethod(); }; -} // namespace test -} // namespace containers -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb #include "./set_test-inl.h" -#endif // CONTAINERS_CPP_TEST_SET_TEST_H_ \ No newline at end of file +#endif // CONTAINERS_CPP_TEST_SET_TEST_H_