diff --git a/CMakeLists.txt b/CMakeLists.txt index df96ec692..5e9ef97eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ option (USE_HDF5 "HDF5 File format" OFF) option (USE_TEXTCLIENT "Text Client" OFF) option (USE_RECEIVER "Receiver" OFF) option (USE_GUI "GUI" OFF) -option (USE_TESTS "TESTS" OFF) +option (USE_TESTS "TESTS" ON) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -Wno-misleading-indentation") diff --git a/slsSupportLib/include/Timer.h b/slsSupportLib/include/Timer.h index a16761081..70b339b5b 100644 --- a/slsSupportLib/include/Timer.h +++ b/slsSupportLib/include/Timer.h @@ -5,34 +5,28 @@ #include class Timer { - using clock = std::chrono::high_resolution_clock; + using clock = std::chrono::high_resolution_clock; using time_point = std::chrono::time_point; -public: + public: Timer(std::string name = "0") - : t0(clock::now()) - , name_(name) - { + : t0(clock::now()), name_(name) { } - double elapsed_ms() - { + double elapsed_ms() { return std::chrono::duration(clock::now() - t0).count(); } - double elapsed_s() - { + double elapsed_s() { return std::chrono::duration(clock::now() - t0).count(); } - void print_elapsed() - { + void print_elapsed() { std::cout << "Timer \"" << name_ << "\": Elapsed time " << elapsed_ms() << " ms\n"; } - void restart() - { + void restart() { t0 = clock::now(); } -private: + private: time_point t0; std::string name_; }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a75a89e5a..75559566f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories( ${PROJECT_SOURCE_DIR}/catch ${PROJECT_SOURCE_DIR}/slsSupportLib/include ${PROJECT_SOURCE_DIR}/slsDetectorSoftware/multiSlsDetector + ${PROJECT_SOURCE_DIR}/slsDetectorSoftware/sharedMemory ) @@ -15,7 +16,8 @@ if(USE_TESTS) set(LOCAL_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(TEST_SOURCES ${LOCAL_TEST_DIR}/test-container_utils.cpp - ${LOCAL_TEST_DIR}/test-multiDetector.cpp + ${LOCAL_TEST_DIR}/test-MySocketTCP.cpp + #${LOCAL_TEST_DIR}/test-multiDetector.cpp ${LOCAL_TEST_DIR}/test.cpp # PARENT_SCOPE ) @@ -23,6 +25,7 @@ if(USE_TESTS) target_link_libraries(test slsDetectorShared pthread + rt ) set_target_properties(test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin diff --git a/tests/src/test-MySocketTCP.cpp b/tests/src/test-MySocketTCP.cpp new file mode 100644 index 000000000..550775fa7 --- /dev/null +++ b/tests/src/test-MySocketTCP.cpp @@ -0,0 +1,13 @@ +#include "catch.hpp" +#include "MySocketTCP.h" +// #include "multiSlsDetector.h" +#include +TEST_CASE("Construct") { + + +// MySocketTCP(const char* const host_ip_or_name, unsigned short int const port_number): genericSocket(host_ip_or_name, port_number,TCP){setPacketSize(TCP_PACKET_SIZE);}; // sender (client): where to? ip + unsigned short int const port_number = 1966; + auto receiver = MySocketTCP(port_number); + REQUIRE(false); + +} \ No newline at end of file diff --git a/tests/src/test-container_utils.cpp b/tests/src/test-container_utils.cpp index 10c8c8b9a..4f1704319 100644 --- a/tests/src/test-container_utils.cpp +++ b/tests/src/test-container_utils.cpp @@ -7,7 +7,6 @@ using sls::allEqual; using sls::allEqualTo; using sls::anyEqualTo; - using sls::allEqualToWithTol; using sls::allEqualWithTol; using sls::anyEqualToWithTol; diff --git a/tests/src/test-multiDetector.cpp b/tests/src/test-multiDetector.cpp index 3131b6462..ca16cae56 100644 --- a/tests/src/test-multiDetector.cpp +++ b/tests/src/test-multiDetector.cpp @@ -1,11 +1,11 @@ -#include "catch.hpp" -#include "multiSlsDetector.h" +// #include "catch.hpp" +// #include "multiSlsDetector.h" -#include -TEST_CASE("Initialize a detector") { -multiSlsDetector det(0, true, true); - std::cout << "Size: " << det.getNumberOfDetectors() << std::endl; - std::cout << "Hostname: " << det.getHostname() << std::endl; - REQUIRE(false); +// #include +// TEST_CASE("Initialize a detector") { +// multiSlsDetector det(0, true, true); +// std::cout << "Size: " << det.getNumberOfDetectors() << std::endl; +// std::cout << "Hostname: " << det.getHostname() << std::endl; +// REQUIRE(false); -} \ No newline at end of file +// } \ No newline at end of file