diff --git a/tests/s25Main/campaign/testCampaignLuaFile.cpp b/tests/s25Main/campaign/testCampaignLuaFile.cpp index e5de2acec..1992d8342 100644 --- a/tests/s25Main/campaign/testCampaignLuaFile.cpp +++ b/tests/s25Main/campaign/testCampaignLuaFile.cpp @@ -22,14 +22,28 @@ BOOST_AUTO_TEST_SUITE(CampaignLuaFile) BOOST_AUTO_TEST_CASE(ScriptVersion) { - // No getRequiredLuaVersion + rttr::test::TmpFolder tmp; + const auto campaignFile = tmp / "campaign.lua"; { - rttr::test::TmpFolder tmp; - { - bnw::ofstream file(tmp / "campaign.lua"); - file << ""; - } + bnw::ofstream file(campaignFile); + + file << "campaign ={\ + version = \"1\",\ + author = \"Max Meier\",\ + name = \"Meine Kampagne\",\ + shortDescription = \"Sehr kurze Beschreibung\",\ + longDescription = \"Das ist die lange Beschreibung\",\ + image = \"/GFX/PICS/WORLD.LBM\",\ + maxHumanPlayers = 1,\ + difficulty = \"easy\",\ + mapFolder = \"/DATA/MAPS\",\ + luaFolder = \"/CAMPAIGNS/ROMAN\",\ + maps = { \"dessert0.WLD\", \"dessert1.WLD\", \"dessert2.WLD\"}\ + }\n"; + } + // No getRequiredLuaVersion + { CampaignDescription desc; CampaignDataLoader loader(desc, tmp); rttr::test::LogAccessor logAcc; @@ -40,41 +54,25 @@ BOOST_AUTO_TEST_CASE(ScriptVersion) // Correct version { - rttr::test::TmpFolder tmp; { - bnw::ofstream file(tmp / "campaign.lua"); - file << helpers::format("function getRequiredLuaVersion()\n return %1%\n end", + bnw::ofstream file(campaignFile, std::ios::app); + file << helpers::format("function getRequiredLuaVersion()\n return %1%\n end\n", CampaignDataLoader::GetVersion()); } CampaignDescription desc; CampaignDataLoader loader(desc, tmp); rttr::test::LogAccessor logAcc; - BOOST_TEST_REQUIRE(!loader.Load()); + BOOST_TEST_REQUIRE(loader.Load()); BOOST_TEST(loader.CheckScriptVersion()); logAcc.clearLog(); } // Backwards compatibility: version 2 can load version 1 { - rttr::test::TmpFolder tmp; { - bnw::ofstream file(tmp / "campaign.lua"); - - file << "campaign ={\ - version = \"1\",\ - author = \"Max Meier\",\ - name = \"Meine Kampagne\",\ - shortDescription = \"Sehr kurze Beschreibung\",\ - longDescription = \"Das ist die lange Beschreibung\",\ - image = \"/GFX/PICS/WORLD.LBM\",\ - maxHumanPlayers = 1,\ - difficulty = \"easy\",\ - mapFolder = \"/DATA/MAPS\",\ - luaFolder = \"/CAMPAIGNS/ROMAN\",\ - maps = { \"dessert0.WLD\", \"dessert1.WLD\", \"dessert2.WLD\"}\ - }\ - function getRequiredLuaVersion()\n return 1\n end"; + bnw::ofstream file(tmp / "campaign.lua", std::ios::app); + file << "function getRequiredLuaVersion()\n return 1\n end\n"; } CampaignDescription desc; @@ -88,14 +86,12 @@ BOOST_AUTO_TEST_CASE(ScriptVersion) // Wrong version { - BOOST_TEST_PASSPOINT(); - rttr::test::TmpFolder tmp; BOOST_TEST_PASSPOINT(); { BOOST_TEST_PASSPOINT(); - bnw::ofstream file(tmp / "campaign.lua"); + bnw::ofstream file(tmp / "campaign.lua", std::ios::app); BOOST_TEST_PASSPOINT(); - file << helpers::format("function getRequiredLuaVersion()\n return %1%\n end", + file << helpers::format("function getRequiredLuaVersion()\n return %1%\n end\n", CampaignDataLoader::GetVersion() + 1); BOOST_TEST_PASSPOINT(); }