|
1 | | -// Copyright (C) 2005 - 2024 Settlers Freaks (sf-team at siedler25.org) |
| 1 | +// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org) |
2 | 2 | // |
3 | 3 | // SPDX-License-Identifier: GPL-2.0-or-later |
4 | 4 |
|
5 | 5 | #include "PointOutput.h" |
6 | 6 | #include "TerrainBQOutput.h" |
| 7 | +#include "files.h" |
7 | 8 | #include "helpers/Range.h" |
8 | 9 | #include "helpers/containerUtils.h" |
9 | 10 | #include "legacy/TerrainData.h" |
10 | 11 | #include "lua/GameDataLoader.h" |
11 | 12 | #include "gameData/EdgeDesc.h" |
12 | 13 | #include "gameData/TerrainDesc.h" |
13 | 14 | #include "gameData/WorldDescription.h" |
| 15 | +#include "rttr/test/ConfigOverride.hpp" |
14 | 16 | #include "rttr/test/LogAccessor.hpp" |
15 | 17 | #include "rttr/test/TmpFolder.hpp" |
16 | 18 | #include <boost/filesystem.hpp> |
@@ -113,6 +115,29 @@ BOOST_AUTO_TEST_CASE(LoadGameData) |
113 | 115 | // TerrainData::PrintEdgePrios(); |
114 | 116 | } |
115 | 117 |
|
| 118 | +BOOST_AUTO_TEST_CASE(DetectError) |
| 119 | +{ |
| 120 | + rttr::test::TmpFolder tmp; |
| 121 | + rttr::test::ConfigOverride _("RTTR", tmp); |
| 122 | + auto worldPath = RTTRCONFIG.ExpandPath(s25::folders::gamedata) / "world"; |
| 123 | + create_directories(worldPath); |
| 124 | + { |
| 125 | + bnw::ofstream file(worldPath / "default.lua"); |
| 126 | + BOOST_TEST_REQUIRE(!!(file << "empty = true")); |
| 127 | + } |
| 128 | + WorldDescription desc; |
| 129 | + BOOST_REQUIRE_NO_THROW(loadGameData(desc)); |
| 130 | + |
| 131 | + { |
| 132 | + bnw::ofstream file(worldPath / "default.lua"); |
| 133 | + BOOST_TEST_REQUIRE(!!(file << "syntax{-error")); |
| 134 | + } |
| 135 | + GameDataLoader loader(desc, tmp); |
| 136 | + rttr::test::LogAccessor logAcc; |
| 137 | + BOOST_TEST(!loader.Load()); |
| 138 | + BOOST_CHECK_THROW(loadGameData(desc), std::runtime_error); |
| 139 | +} |
| 140 | + |
116 | 141 | BOOST_AUTO_TEST_CASE(DetectRecursion) |
117 | 142 | { |
118 | 143 | rttr::test::TmpFolder tmp; |
|
0 commit comments