mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
changed constructor
This commit is contained in:
@ -1,60 +0,0 @@
|
||||
MESSAGE( STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )
|
||||
|
||||
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/catch
|
||||
${PROJECT_SOURCE_DIR}/slsSupportLib/include
|
||||
${PROJECT_SOURCE_DIR}/slsDetectorSoftware/multiSlsDetector
|
||||
${PROJECT_SOURCE_DIR}/slsDetectorSoftware/sharedMemory
|
||||
)
|
||||
|
||||
|
||||
|
||||
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-string_utils.cpp
|
||||
${LOCAL_TEST_DIR}/test-MySocketTCP.cpp
|
||||
${LOCAL_TEST_DIR}/test-CmdLineParser.cpp
|
||||
#${LOCAL_TEST_DIR}/test-multiDetector.cpp
|
||||
${LOCAL_TEST_DIR}/test.cpp
|
||||
)
|
||||
add_executable(test ${TEST_SOURCES})
|
||||
target_link_libraries(test
|
||||
slsDetectorShared
|
||||
pthread
|
||||
rt
|
||||
)
|
||||
set_target_properties(test PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
#option(USE_TESTS "Determines whether to build tests." OFF)
|
||||
# if(USE_TESTS)
|
||||
# # Prepare "Catch" library for other executables
|
||||
# set(CATCH_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/catch)
|
||||
# add_library(Catch INTERFACE)
|
||||
# target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
|
||||
|
||||
# # Make test executable
|
||||
# add_executable(tests ${BASE_TEST_SOURCES})
|
||||
# target_link_libraries(tests Catch)
|
||||
|
||||
# set_target_properties(tests PROPERTIES
|
||||
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
# )
|
||||
|
||||
# #enable_testing()
|
||||
# #add_test(NAME CommandLineClient COMMAND tests)
|
||||
|
||||
# endif()
|
||||
|
||||
|
||||
# install(TARGETS sls_client DESTINATION bin)
|
||||
|
@ -1,87 +0,0 @@
|
||||
#include "MySocketTCP.h"
|
||||
#include "catch.hpp"
|
||||
// #include "multiSlsDetector.h"
|
||||
#include "logger.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#define VERBOSE
|
||||
|
||||
TEST_CASE("Sending and receiving data with two sockets") {
|
||||
|
||||
const int port_number{1966}; //TODO! Avoid hardcoded port number!!!
|
||||
auto sender = MySocketTCP("localhost", port_number);
|
||||
auto receiver = MySocketTCP(port_number);
|
||||
|
||||
auto s = sender.Connect();
|
||||
auto r = receiver.Connect();
|
||||
|
||||
REQUIRE(s > 0);
|
||||
REQUIRE(r > 0);
|
||||
REQUIRE(sender.getPortNumber() == port_number);
|
||||
REQUIRE(receiver.getPortNumber() == port_number);
|
||||
|
||||
std::vector<char> message_to_send{'H', 'e', 'l', 'l', 'o'};
|
||||
std::vector<char> received_message(message_to_send.size());
|
||||
|
||||
auto sent = sender.SendDataOnly(message_to_send.data(), message_to_send.size());
|
||||
auto received = receiver.ReceiveDataOnly(received_message.data(), message_to_send.size());
|
||||
REQUIRE(sent == message_to_send.size());
|
||||
REQUIRE(received == received_message.size());
|
||||
REQUIRE(sent == received);
|
||||
REQUIRE(message_to_send == received_message);
|
||||
|
||||
receiver.CloseServerTCPSocketDescriptor();
|
||||
receiver.Disconnect();
|
||||
sender.Disconnect();
|
||||
|
||||
REQUIRE(receiver.getsocketDescriptor() == -1);
|
||||
REQUIRE(receiver.getFileDes() == -1);
|
||||
REQUIRE(sender.getFileDes() == -1);
|
||||
}
|
||||
|
||||
TEST_CASE("Open two sockets on the same port fails and throws") {
|
||||
const int port_number{1966};
|
||||
auto server = MySocketTCP(port_number);
|
||||
CHECK_THROWS(MySocketTCP(port_number));
|
||||
}
|
||||
|
||||
// TEST_CASE("Conversions"){
|
||||
|
||||
// std::cout << "name " << MySocketTCP::nameToMac("enp10s0u1u3u3") << '\n';
|
||||
|
||||
// }
|
||||
|
||||
// TEST_CASE("Have two clients connect to the same server") {
|
||||
// const int port_number{1966};
|
||||
|
||||
// auto server = MySocketTCP(port_number);
|
||||
|
||||
// auto client1 = MySocketTCP("localhost", port_number);
|
||||
// auto client2 = MySocketTCP("localhost", port_number);
|
||||
// client1.SetTimeOut(1);
|
||||
// client2.SetTimeOut(1);
|
||||
// server.SetTimeOut(1);
|
||||
|
||||
// auto fd1 = client1.Connect();
|
||||
// auto fd2 = client2.Connect();
|
||||
|
||||
// server.Connect();
|
||||
|
||||
// REQUIRE(fd1 > 0);
|
||||
// REQUIRE(fd2 > 0);
|
||||
|
||||
// std::cout << "fd1 " << fd1 << '\n';
|
||||
// std::cout << "fd2 " << fd2 << '\n';
|
||||
|
||||
// std::vector<char> message_to_send{'H', 'e', 'l', 'l', 'o'};
|
||||
// std::vector<char> received_message(message_to_send.size());
|
||||
|
||||
// client1.SendDataOnly(message_to_send.data(), message_to_send.size());
|
||||
// auto n1 = server.ReceiveDataOnly(received_message.data(), received_message.size());
|
||||
// std::cout << "n1 " << n1 << '\n';
|
||||
|
||||
// client2.SendDataOnly(message_to_send.data(), message_to_send.size());
|
||||
// auto n2 = server.ReceiveDataOnly(received_message.data(), received_message.size());
|
||||
// std::cout << "n2 " << n2 << '\n';
|
||||
// }
|
@ -1,11 +0,0 @@
|
||||
// #include "catch.hpp"
|
||||
// #include "multiSlsDetector.h"
|
||||
|
||||
// #include <iostream>
|
||||
// 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);
|
||||
|
||||
// }
|
@ -1,3 +0,0 @@
|
||||
// tests-main.cpp
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
Reference in New Issue
Block a user