diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index db81156..d20aeb8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,6 +18,7 @@ cmake_minimum_required(VERSION 3.13) +add_subdirectory(event_test) add_subdirectory(expmap_test) add_subdirectory(serialization_test) add_subdirectory(topic2mcast_test) diff --git a/tests/event_test/CMakeLists.txt b/tests/event_test/CMakeLists.txt new file mode 100644 index 0000000..94db260 --- /dev/null +++ b/tests/event_test/CMakeLists.txt @@ -0,0 +1,42 @@ +# ========================= eCAL LICENSE ================================= +# +# Copyright (C) 2016 - 2019 Continental Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ========================= eCAL LICENSE ================================= + +project(test_event) + +find_package(Threads REQUIRED) +find_package(GTest REQUIRED) + +set(event_test_src + src/event_test.cpp + ../../src/core/src/ecal_event.cpp +) + +ecal_add_gtest(${PROJECT_NAME} ${event_test_src}) + +target_include_directories(${PROJECT_NAME} PRIVATE $) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + eCAL::core + Threads::Threads) + +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) + +ecal_install_gtest(${PROJECT_NAME}) + +set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER testing/ecal/io) diff --git a/tests/event_test/src/event_test.cpp b/tests/event_test/src/event_test.cpp new file mode 100644 index 0000000..1c538c9 --- /dev/null +++ b/tests/event_test/src/event_test.cpp @@ -0,0 +1,41 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2019 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +#include "ecal_event.h" + +#include + +TEST(Event, EventSetGet) +{ + // global parameter + const std::string event_name = "my_event"; + + // create named event + eCAL::EventHandleT event_handle; + EXPECT_EQ(true, eCAL::gOpenEvent(&event_handle, event_name)); + + // get none set event + EXPECT_EQ(false, gWaitForEvent(event_handle, 10)); + + // set event + EXPECT_EQ(true, gSetEvent(event_handle)); + + // get set event + EXPECT_EQ(true, gWaitForEvent(event_handle, 100)); +}