From 3f0eeec42979d96716bb27875f7e77d655e087be Mon Sep 17 00:00:00 2001 From: Damon Kohler Date: Fri, 18 Nov 2016 09:48:54 +0100 Subject: [PATCH] Adds configuration files test. (#129) --- cartographer/common/CMakeLists.txt | 9 ++++ cartographer/common/config.h.cmake | 1 + .../common/configuration_files_test.cc | 45 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 cartographer/common/configuration_files_test.cc diff --git a/cartographer/common/CMakeLists.txt b/cartographer/common/CMakeLists.txt index d2f215c..a608b5f 100644 --- a/cartographer/common/CMakeLists.txt +++ b/cartographer/common/CMakeLists.txt @@ -171,6 +171,15 @@ google_test(common_blocking_queue_test common_time ) +google_test(common_configuration_files_test + SRCS + configuration_files_test.cc + DEPENDS + common_configuration_file_resolver + common_lua_parameter_dictionary + mapping_map_builder +) + google_test(common_fixed_ratio_sampler_test SRCS fixed_ratio_sampler_test.cc diff --git a/cartographer/common/config.h.cmake b/cartographer/common/config.h.cmake index 4658986..c026320 100644 --- a/cartographer/common/config.h.cmake +++ b/cartographer/common/config.h.cmake @@ -22,6 +22,7 @@ namespace common { constexpr char kConfigurationFilesDirectory[] = "@CARTOGRAPHER_CONFIGURATION_FILES_DIRECTORY@"; +constexpr char kSourceDirectory[] = "@CMAKE_SOURCE_DIR@"; } // namespace common } // namespace cartographer diff --git a/cartographer/common/configuration_files_test.cc b/cartographer/common/configuration_files_test.cc new file mode 100644 index 0000000..88b6d1a --- /dev/null +++ b/cartographer/common/configuration_files_test.cc @@ -0,0 +1,45 @@ +/* + * Copyright 2016 The Cartographer Authors + * + * 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 +#include + +#include "cartographer/common/config.h" +#include "cartographer/common/configuration_file_resolver.h" +#include "cartographer/common/lua_parameter_dictionary.h" +#include "cartographer/mapping/map_builder.h" +#include "gtest/gtest.h" + +namespace cartographer_ros { +namespace { + +TEST(ConfigurationFilesTest, ValidateMapBuilderOptions) { + const string kCode = R"text( + include "map_builder.lua" + MAP_BUILDER.use_trajectory_builder_2d = true + return MAP_BUILDER)text"; + EXPECT_NO_FATAL_FAILURE({ + auto file_resolver = ::cartographer::common::make_unique< + ::cartographer::common::ConfigurationFileResolver>(std::vector{ + string(::cartographer::common::kSourceDirectory) + "/configuration_files"}); + ::cartographer::common::LuaParameterDictionary lua_parameter_dictionary( + kCode, std::move(file_resolver)); + ::cartographer::mapping::CreateMapBuilderOptions(&lua_parameter_dictionary); + }); +} + +} // namespace +} // namespace cartographer_ros