Skip to content

Commit

Permalink
event_test added again
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-schilasky committed Feb 6, 2024
1 parent ea07510 commit a37b475
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 42 additions & 0 deletions tests/event_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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_PROPERTY:eCAL::core,INCLUDE_DIRECTORIES>)

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)
41 changes: 41 additions & 0 deletions tests/event_test/src/event_test.cpp
Original file line number Diff line number Diff line change
@@ -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 <gtest/gtest.h>

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));
}

0 comments on commit a37b475

Please sign in to comment.