TestLanelet2Io.cpp
Go to the documentation of this file.
1 #include "TestSetup.h"
2 #include "gtest/gtest.h"
4 #include "lanelet2_io/Io.h"
5 
6 TEST(lanelet2_io, registryTest) { // NOLINT
7  auto parseExtensions = lanelet::supportedParserExtensions();
8  EXPECT_NE(std::find(parseExtensions.begin(), parseExtensions.end(), ".osm"), parseExtensions.end());
9  EXPECT_NE(std::find(parseExtensions.begin(), parseExtensions.end(), ".bin"), parseExtensions.end());
10 
11  auto writeExtensions = lanelet::supportedWriterExtensions();
12  EXPECT_NE(std::find(writeExtensions.begin(), writeExtensions.end(), ".osm"), writeExtensions.end());
13  EXPECT_NE(std::find(writeExtensions.begin(), writeExtensions.end(), ".bin"), writeExtensions.end());
14 }
15 
16 TEST(lanelet2_io, exceptionTest) { // NOLINT
17  lanelet::test_setup::Tempfile file("file_with.unsupported_extension");
18  file.touch();
19  EXPECT_THROW(lanelet::load(file.get().string()), lanelet::UnsupportedExtensionError); // NOLINT
20  EXPECT_THROW(lanelet::load(file.get().string(), "nonexisting_parser"), lanelet::UnsupportedIOHandlerError); // NOLINT
21  EXPECT_THROW(lanelet::load("/nonexisting/file/with/known/extension.osm"), lanelet::FileNotFoundError); // NOLINT
22 }
TestSetup.h
lanelet::UnsupportedExtensionError
Error for an unsupported extension.
Definition: Exceptions.h:27
lanelet::test_setup::Tempfile
Definition: TestSetup.h:124
file
osm::File & file
Definition: OsmHandlerWrite.cpp:245
lanelet::supportedWriterExtensions
std::vector< std::string > supportedWriterExtensions()
returns the names of the currently supported extensions for writing (including the dot)
Definition: Io.cpp:84
Io.h
lanelet::load
std::unique_ptr< LaneletMap > load(const std::string &filename, const Origin &origin=Origin::defaultOrigin(), ErrorMessages *errors=nullptr, const io::Configuration &params=io::Configuration())
Loads a lanelet map from a file.
Definition: Io.cpp:24
lanelet::FileNotFoundError
Error for not existent filepaths.
Definition: Exceptions.h:20
lanelet::supportedParserExtensions
std::vector< std::string > supportedParserExtensions()
Definition: Io.cpp:59
lanelet::UnsupportedIOHandlerError
Error thrown if an unsupported handler (parser/writer) has been specified.
Definition: Exceptions.h:35
TEST
TEST(lanelet2_io, registryTest)
Definition: TestLanelet2Io.cpp:6
Exceptions.h


lanelet2_io
Author(s): Fabian Poggenhans
autogenerated on Thu Mar 6 2025 03:26:03