add logic tests executable

This commit is contained in:
gymnast86
2026-08-02 01:48:58 -07:00
parent e93a720d8f
commit 2b489e1a7d
3 changed files with 37 additions and 34 deletions
+25 -28
View File
@@ -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;
}