Skip to content

Commit

Permalink
Improvements to enable "-Wconversion" (#46)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <michael@openrobotics.org>
  • Loading branch information
mjcarroll authored Mar 29, 2022
1 parent 33b0705 commit 2a8a47a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
9 changes: 5 additions & 4 deletions src/NeverDestroyed_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ GTEST_TEST(NeverDestroyedExample, ParseFoo)

// This is an example from the class overview API docs; we repeat it here to
// ensure it remains valid.
const std::vector<double> &GetConstantMagicNumbers()
using Result = std::vector<std::uint_fast32_t>;
const Result &GetConstantMagicNumbers()
{
static const ignition::utils::NeverDestroyed<std::vector<double>> result{
static const ignition::utils::NeverDestroyed<Result> result{
[]()
{
std::vector<double> prototype;
Result prototype;
std::mt19937 random_generator;
for (int i = 0; i < 10; ++i)
{
double new_value = random_generator();
auto new_value = random_generator();
prototype.push_back(new_value);
}
return prototype;
Expand Down
15 changes: 8 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
configure_file (test_config.h.in ${PROJECT_BINARY_DIR}/test_config.h)
include_directories (
${PROJECT_SOURCE_DIR}/test/gtest/include
${PROJECT_SOURCE_DIR}/test/gtest
${PROJECT_SOURCE_DIR}/test
${CMAKE_BINARY_DIR}/include
${PROJECT_BINARY_DIR}/include
)

configure_file (test_config.h.in ${PROJECT_BINARY_DIR}/test_config.h)

# Build gtest
add_library(gtest STATIC gtest/src/gtest-all.cc)
add_library(gtest_main STATIC gtest/src/gtest_main.cc)
target_include_directories(gtest
SYSTEM PUBLIC
${PROJECT_SOURCE_DIR}/test/gtest/include
${PROJECT_SOURCE_DIR}/test/gtest
)

target_link_libraries(gtest_main gtest)
set_property(TARGET gtest_main PROPERTY CXX_STANDARD ${c++standard})
set_property(TARGET gtest PROPERTY CXX_STANDARD ${c++standard})
Expand All @@ -18,7 +20,6 @@ set(GTEST_MAIN_LIBRARY "${PROJECT_BINARY_DIR}/test/libgtest_main.a")

execute_process(COMMAND cmake -E remove_directory ${CMAKE_BINARY_DIR}/test_results)
execute_process(COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test_results)
include_directories(${GTEST_INCLUDE_DIRS})

#============================================================================
# Do a fake install of ign-utils in order to test the examples.
Expand Down

0 comments on commit 2a8a47a

Please # to comment.