mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-07 09:45:33 -04:00
add logic tests executable
This commit is contained in:
@@ -1,42 +1,39 @@
|
||||
#include "test.hpp"
|
||||
|
||||
#include "../randomizer.hpp"
|
||||
#include "../utility/string.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
|
||||
namespace randomizer::test::test
|
||||
int main()
|
||||
{
|
||||
void RunTests()
|
||||
for (const auto& entry : std::filesystem::recursive_directory_iterator(RANDO_LOGIC_TESTS_PATH))
|
||||
{
|
||||
for (const auto& entry : std::filesystem::recursive_directory_iterator(RANDO_LOGIC_TESTS_PATH))
|
||||
if (entry.path().generic_string().ends_with("settings.yaml"))
|
||||
{
|
||||
if (entry.path().generic_string().ends_with("settings.yaml"))
|
||||
{
|
||||
auto pathFolders = utility::str::Split(entry.path().generic_string(), '/');
|
||||
auto& testName = pathFolders[pathFolders.size() - 2];
|
||||
std::filesystem::remove(SETTINGS_PATH);
|
||||
std::filesystem::copy_file(entry, SETTINGS_PATH);
|
||||
auto pathFolders = randomizer::utility::str::Split(entry.path().generic_string(), '/');
|
||||
auto& testName = pathFolders[pathFolders.size() - 2];
|
||||
std::filesystem::remove(SETTINGS_PATH);
|
||||
std::filesystem::copy_file(entry, SETTINGS_PATH);
|
||||
|
||||
std::cout << "Testing " << testName << std::endl;
|
||||
std::cout << "Testing " << testName << std::endl;
|
||||
|
||||
try {
|
||||
Randomizer r{RANDO_SAVE_PATH};
|
||||
r.GenerateWorlds();
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::cout << "Test \"" << testName << "\" failed! Failed settings saved to " << SETTINGS_PATH << std::endl;
|
||||
std::cout << "Error Message: " << e.what() << std::endl;
|
||||
throw;
|
||||
}
|
||||
|
||||
std::filesystem::remove(SETTINGS_PATH);
|
||||
try {
|
||||
randomizer::Randomizer r{RANDO_SAVE_PATH};
|
||||
r.GenerateWorlds();
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::cout << "Test \"" << testName << "\" failed! Failed settings saved to " << SETTINGS_PATH << std::endl;
|
||||
std::cout << "Error Message: " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// Remove test preferences
|
||||
std::filesystem::remove(PREFERENCES_PATH);
|
||||
|
||||
std::cout << "All Settings Tests passed" << std::endl;
|
||||
std::filesystem::remove(SETTINGS_PATH);
|
||||
}
|
||||
}
|
||||
} // namespace randomizer::test::test
|
||||
// Remove test preferences
|
||||
std::filesystem::remove(PREFERENCES_PATH);
|
||||
|
||||
std::cout << "All Settings Tests passed" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user