mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-18 10:34:30 +01:00
default args
This commit is contained in:
23
slsDetectorSoftware/tests/CMakeLists.txt
Normal file
23
slsDetectorSoftware/tests/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/catch
|
||||
)
|
||||
|
||||
set(SOURCES
|
||||
test.cpp
|
||||
test-SharedMemory.cpp
|
||||
)
|
||||
|
||||
add_executable(testSlsDetector ${SOURCES})
|
||||
target_link_libraries(testSlsDetector
|
||||
slsSupportLib
|
||||
slsDetectorShared
|
||||
pthread
|
||||
rt
|
||||
)
|
||||
set_target_properties(testSlsDetector PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
#TODO! Move to automatic test discovery
|
||||
add_test(test-testSlsDetector ${CMAKE_BINARY_DIR}/bin/testSlsDetector)
|
||||
30
slsDetectorSoftware/tests/test-SharedMemory.cpp
Normal file
30
slsDetectorSoftware/tests/test-SharedMemory.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
#include "catch.hpp"
|
||||
#include "SharedMemory.h"
|
||||
#include "string_utils.h"
|
||||
|
||||
|
||||
TEST_CASE("SharedMemory") {
|
||||
struct Data{
|
||||
int x;
|
||||
double y;
|
||||
char mess[50];
|
||||
};
|
||||
|
||||
|
||||
SharedMemory<Data> shm(0,-1);
|
||||
shm.CreateSharedMemory();
|
||||
CHECK(shm.GetName() == "/slsDetectorPackage_multi_0");
|
||||
|
||||
shm()->x = 3;
|
||||
shm()->y = 5.7;
|
||||
sls::strcpy_safe(shm()->mess, "Some string");
|
||||
|
||||
CHECK(shm()->x == 3);
|
||||
CHECK(shm()->y == 5.7);
|
||||
CHECK(std::string(shm()->mess) == "Some string");
|
||||
|
||||
shm.UnmapSharedMemory();
|
||||
shm.RemoveSharedMemory();
|
||||
|
||||
}
|
||||
3
slsDetectorSoftware/tests/test.cpp
Normal file
3
slsDetectorSoftware/tests/test.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
// tests-main.cpp
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
Reference in New Issue
Block a user