Skip to content

Commit 5085018

Browse files
committed
Unit test for Return error when Lua tag transform cannot be read
1 parent abdcc76 commit 5085018

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/test-options-parse.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,25 @@ void test_outputs()
132132
}
133133
}
134134

135+
void test_lua_styles()
136+
{
137+
#ifdef HAVE_LUA
138+
const char* a1[] = {"osm2pgsql", "--tag-transform-script", "non_existing.lua", "tests/liechtenstein-2013-08-03.osm.pbf"};
139+
options_t options = options_t(len(a1), const_cast<char **>(a1));
140+
141+
try
142+
{
143+
std::unique_ptr<tagtransform_t> tagtransform = tagtransform_t::make_tagtransform(&options);
144+
throw std::logic_error("Expected 'No such file or directory'");
145+
}
146+
catch(const std::runtime_error& e)
147+
{
148+
if(!alg::icontains(e.what(), "No such file or directory"))
149+
throw std::logic_error((boost::format("Expected 'No such file or directory' but instead got '%1%'") % e.what()).str());
150+
}
151+
#endif
152+
}
153+
135154
void test_parsing_tile_expiry_zoom_levels()
136155
{
137156
const char *a1[] = {
@@ -430,6 +449,7 @@ int main(int argc, char *argv[])
430449
run_test("test_incompatible_args", test_incompatible_args);
431450
run_test("test_middles", test_middles);
432451
run_test("test_outputs", test_outputs);
452+
run_test("test_lua_styles", test_lua_styles);
433453
run_test("test_random_perms", test_random_perms);
434454
run_test("test_parsing_tile_expiry_zoom_levels_fails",
435455
test_parsing_tile_expiry_zoom_levels_fails);

0 commit comments

Comments
 (0)