Skip to content

Commit

Permalink
Adds configuration files test. (cartographer-project#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
damonkohler authored Nov 18, 2016
1 parent 4522fc4 commit 3f0eeec
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cartographer/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions cartographer/common/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace common {

constexpr char kConfigurationFilesDirectory[] =
"@CARTOGRAPHER_CONFIGURATION_FILES_DIRECTORY@";
constexpr char kSourceDirectory[] = "@CMAKE_SOURCE_DIR@";

} // namespace common
} // namespace cartographer
Expand Down
45 changes: 45 additions & 0 deletions cartographer/common/configuration_files_test.cc
Original file line number Diff line number Diff line change
@@ -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 <string>
#include <vector>

#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>{
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

0 comments on commit 3f0eeec

Please sign in to comment.