Skip to content

Commit

Permalink
Tests to rmw_participant_qos_profile_t_allocator
Browse files Browse the repository at this point in the history
Signed-off-by: Jaison Titus <jaisontj92@gmail.com>
  • Loading branch information
jaisontj committed Oct 4, 2019
1 parent f138591 commit 36e4a68
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rmw/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ if(TARGET test_validate_namespace)
set_target_properties(test_validate_namespace PROPERTIES COMPILE_FLAGS "-std=c++14")
endif()
endif()

ament_add_gmock(test_rmw_participant_qos_profile_allocator
test_rmw_participant_qos_profile_allocator.cpp
# Append the directory of librmw so it is found at test time.
APPEND_LIBRARY_DIRS "$<TARGET_FILE_DIR:${PROJECT_NAME}>"
)
if(TARGET test_rmw_participant_qos_profile_allocator)
target_link_libraries(test_rmw_participant_qos_profile_allocator ${PROJECT_NAME})
endif()
38 changes: 38 additions & 0 deletions rmw/test/test_rmw_participant_qos_profile_allocator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2018 Open Source Robotics Foundation, Inc.
//
// 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.

#include "gtest/gtest.h"

#include "rmw/allocators.h"
#include "rmw/types.h"

TEST(test_rmw_participant_qos_profile_allocator, test_allocate_does_not_return_null) {
rmw_participant_qos_profile_t * qos_profile = rmw_participant_qos_profile_allocate();
ASSERT_TRUE(qos_profile != NULL);
}

TEST(test_rmw_participant_qos_profile_allocator, test_allocate_allocates_different_pointers) {
rmw_participant_qos_profile_t * qos_profile1 = rmw_participant_qos_profile_allocate();
rmw_participant_qos_profile_t * qos_profile2 = rmw_participant_qos_profile_allocate();
ASSERT_TRUE(qos_profile1 != qos_profile2);
}

TEST(test_rmw_participant_qos_profile_allocator, test_free_null) {
EXPECT_NO_THROW(rmw_participant_qos_profile_free(NULL));
}

TEST(test_rmw_participant_qos_profile_allocator, test_free_allocated) {
rmw_participant_qos_profile_t * qos_profile = rmw_participant_qos_profile_allocate();
EXPECT_NO_THROW(rmw_participant_qos_profile_free(qos_profile));
}

0 comments on commit 36e4a68

Please sign in to comment.