new tests

This commit is contained in:
Erik Frojdh
2019-04-03 18:11:48 +02:00
parent 697c020a49
commit 0270e18882
11 changed files with 171 additions and 93 deletions

View File

@ -1,23 +1 @@
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)
target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test-SharedMemory.cpp)

View File

@ -13,7 +13,7 @@ struct Data {
using namespace sls;
TEST_CASE("Create SharedMemory read and write") {
TEST_CASE("Create SharedMemory read and write", "[detector]") {
SharedMemory<Data> shm(0, -1);
shm.CreateSharedMemory();
@ -33,7 +33,7 @@ TEST_CASE("Create SharedMemory read and write") {
CHECK(shm.IsExisting() == false);
}
TEST_CASE("Open existing SharedMemory and read") {
TEST_CASE("Open existing SharedMemory and read", "[detector]") {
{
SharedMemory<double> shm(0, -1);
@ -48,7 +48,8 @@ TEST_CASE("Open existing SharedMemory and read") {
shm2.RemoveSharedMemory();
}
TEST_CASE("Creating a second shared memory with the same name throws") {
TEST_CASE("Creating a second shared memory with the same name throws",
"[detector]") {
SharedMemory<double> shm0(0, -1);
SharedMemory<double> shm1(0, -1);
@ -58,7 +59,7 @@ TEST_CASE("Creating a second shared memory with the same name throws") {
shm0.RemoveSharedMemory();
}
TEST_CASE("Open two shared memories to the same place") {
TEST_CASE("Open two shared memories to the same place", "[detector]") {
//Create the first shared memory
SharedMemory<Data> shm(0, -1);
@ -83,8 +84,7 @@ TEST_CASE("Open two shared memories to the same place") {
CHECK(shm2.IsExisting() == false);
}
TEST_CASE("Move SharedMemory"){
TEST_CASE("Move SharedMemory", "[detector]") {
SharedMemory<Data> shm(0,-1);
CHECK(shm.GetName() == "/slsDetectorPackage_multi_0");
@ -105,8 +105,7 @@ TEST_CASE("Move SharedMemory"){
}
TEST_CASE("Create several shared memories") {
TEST_CASE("Create several shared memories", "[detector]") {
constexpr int N = 5;
std::vector<SharedMemory<int>> v;
v.reserve(N);

View File

@ -1,3 +0,0 @@
// tests-main.cpp
#define CATCH_CONFIG_MAIN
#include "catch.hpp"