Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improvements to enable "-Wconversion" #46

Merged
merged 2 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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