Commit f5ca8fe4 by lucapegolotti

containers_cpp: fix cpplint warnings in tests + changin name of test for…

containers_cpp: fix cpplint warnings in tests + changin name of test for blocking push and pop container
parent db171626
......@@ -40,7 +40,7 @@ n_threads(static_cast<int>
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<Container_t>::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;
......
......@@ -26,9 +26,9 @@
#ifndef CONTAINERS_CPP_TEST_BLOCKING_CONTAINER_TEST_H_
#define CONTAINERS_CPP_TEST_BLOCKING_CONTAINER_TEST_H_
#include <embb/base/duration.h>
#include <vector>
#include <partest/partest.h>
#include <embb/base/duration.h>
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
#include "./blocking_container_test-inl.h"
#include "./blocking_push_and_pop_container_test-inl.h"
#endif // CONTAINERS_CPP_TEST_BLOCKING_CONTAINER_TEST_H_
......@@ -35,12 +35,12 @@ namespace containers {
namespace test {
template <typename Container_t>
void BlockingQueueTest<Container_t>::SpecializedPush(const int& element){
void BlockingQueueTest<Container_t>::SpecializedPush(const int& element) {
container.Enqueue(element);
}
template <typename Container_t>
void BlockingQueueTest<Container_t>::SpecializedPop(int& element){
void BlockingQueueTest<Container_t>::SpecializedPop(int& element) {
container.Dequeue(element);
}
......
......@@ -26,20 +26,21 @@
#ifndef CONTAINERS_CPP_TEST_BLOCKING_QUEUE_TEST_H_
#define CONTAINERS_CPP_TEST_BLOCKING_QUEUE_TEST_H_
#include <vector>
#include <partest/partest.h>
#include <./blocking_push_and_pop_container_test.h>
#include <embb/base/duration.h>
#include <./blocking_container_test.h>
#include <vector>
namespace embb {
namespace containers {
namespace test {
template<typename Container_t>
class BlockingQueueTest : public BlockingContainerTest<Container_t> {
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
......
......@@ -44,7 +44,6 @@ void BlockingStackTest<Stack_t>::SpecializedPop(int& element) {
container.Pop(element);
}
} // namespace test
} // namespace containers
} // namespace embb
......
......@@ -26,23 +26,24 @@
#ifndef CONTAINERS_CPP_TEST_BLOCKING_STACK_TEST_H_
#define CONTAINERS_CPP_TEST_BLOCKING_STACK_TEST_H_
#include <vector>
#include <partest/partest.h>
#include <embb/base/duration.h>
#include <./blocking_container_test.h>
#include <./blocking_push_and_pop_container_test.h>
#include <vector>
namespace embb {
namespace containers {
namespace test {
template<typename Stack_t>
class BlockingStackTest : public BlockingContainerTest<Stack_t> {
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 containers
} // namespace embb
#include "./blocking_stack_test-inl.h"
......
......@@ -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<unsigned int>(
2 * partest::TestSuite::GetDefaultNumThreads());
embb_thread_set_max_count(max_threads);
......@@ -96,5 +95,4 @@ PT_MAIN("Data Structures C++") {
PT_RUN(ObjectPoolTest< LockFreeTreeValuePool<bool COMMA false > >);
PT_RUN(ObjectPoolTest< WaitFreeArrayValuePool<bool COMMA false> >);
PT_EXPECT(embb_get_bytes_allocated() == 0);
}
......@@ -27,9 +27,11 @@
#ifndef CONTAINERS_CPP_TEST_MAP_TEST_INL_H_
#define CONTAINERS_CPP_TEST_MAP_TEST_INL_H_
#include <vector>
namespace embb {
namespace containers {
namespace test {
namespace containers {
namespace test {
template <typename T>
MapTest<T>::MapTest() :
......@@ -47,7 +49,6 @@ MapTest<T>::MapTest() :
static_cast<size_t>(n_threads),
static_cast<size_t>(n_iterations)).
Post(&MapTest::MapTest1_Post, this);
}
template <typename T>
......@@ -68,7 +69,6 @@ void MapTest<T>::MapTest1_Pre() {
thread_local_vectors_value[i].push_back(insert_element * 2);
map_contain_vector[static_cast<unsigned int>(insert_element)] = false;
}
}
}
......@@ -103,16 +103,16 @@ void MapTest<T>::MapTest1_ThreadMethod() {
int value = my_values[static_cast<unsigned int>(random_number)];
if (inserting) {
PT_ASSERT(map.Insert(key, value) != map_contain_vector[static_cast<unsigned int>(key)]);
PT_ASSERT(map.Insert(key, value) !=
map_contain_vector[static_cast<unsigned int>(key)]);
map_contain_vector[static_cast<unsigned int>(key)] = true;
}
else {
PT_ASSERT(map.Erase(key) == map_contain_vector[static_cast<unsigned int>(key)]);
} else {
PT_ASSERT(map.Erase(key) ==
map_contain_vector[static_cast<unsigned int>(key)]);
map_contain_vector[static_cast<unsigned int>(key)] = false;
}
}
}
......
......@@ -27,11 +27,12 @@
#ifndef CONTAINERS_CPP_TEST_MAP_TEST_H_
#define CONTAINERS_CPP_TEST_MAP_TEST_H_
#include <vector>
#include <partest/partest.h>
#include <time.h>
#include <embb/base/duration.h>
#include <vector>
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
#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_
......@@ -28,10 +28,11 @@
#ifndef CONTAINERS_CPP_TEST_SET_TEST_INL_H_
#define CONTAINERS_CPP_TEST_SET_TEST_INL_H_
#include <vector>
#include <algorithm>
#include <time.h>
#include <algorithm>
#include <vector>
namespace embb {
namespace containers {
namespace test {
......@@ -55,7 +56,7 @@ SetTest<T>::SetTest() :
}
template <typename T>
void SetTest<T>::SetTest1_Pre(){
void SetTest<T>::SetTest1_Pre() {
embb_internal_thread_index_reset();
thread_local_vectors =
new std::vector<int>[static_cast<unsigned int>(n_threads)];
......@@ -72,7 +73,7 @@ void SetTest<T>::SetTest1_Pre(){
}
template <typename T>
void SetTest<T>::SetTest1_Post(){
void SetTest<T>::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<int>(i)));
......@@ -99,11 +100,12 @@ void SetTest<T>::SetTest1_ThreadMethod() {
int element = my_elements[static_cast<unsigned int>(random_number)];
if (inserting) {
PT_ASSERT(set.Insert(element) != set_contain_vector[static_cast<unsigned int>(element)]);
PT_ASSERT(set.Insert(element) !=
set_contain_vector[static_cast<unsigned int>(element)]);
set_contain_vector[static_cast<unsigned int>(element)] = true;
}
else {
PT_ASSERT(set.Erase(element) == set_contain_vector[static_cast<unsigned int>(element)]);
} else {
PT_ASSERT(set.Erase(element) ==
set_contain_vector[static_cast<unsigned int>(element)]);
set_contain_vector[static_cast<unsigned int>(element)] = false;
}
}
......
......@@ -26,16 +26,17 @@
#ifndef CONTAINERS_CPP_TEST_SET_TEST_H_
#define CONTAINERS_CPP_TEST_SET_TEST_H_
#include <vector>
#include <partest/partest.h>
#include <embb/base/duration.h>
#include <vector>
namespace embb {
namespace containers {
namespace test {
template<typename Set_t>
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<int>* thread_local_vectors;
std::vector<bool> set_contain_vector;
public:
public:
SetTest();
void SetTest1_Pre();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment