Load an out-of-range enum setting as its default
A hand-edited tool=99 or renderType=99 indexed past the end of an array.
This commit is contained in:
1 parent
068d189e6a
commit
e963bc50d3
2 files changed
+36
No files matched your search
@@ -9,6 +9,8 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "audio.h"
|
||||
#include "file.h"
|
||||
#include "settings.h"
|
||||
#include "canvas.h"
|
||||
#include "embed.h"
|
||||
#include "document.h"
|
||||
@@ -406,3 +408,14 @@ TEST_CASE("a second instance hands its paths to the first")
|
||||
CHECK(instance_paths_take() == std::vector<std::string>{});
|
||||
instance_stop();
|
||||
}
|
||||
|
||||
TEST_CASE("hand-edited settings out of an enum's range load as their defaults")
|
||||
{
|
||||
auto path = std::filesystem::temp_directory_path() / "anm2ed_settings_test.ini";
|
||||
REQUIRE(file_text_save(path, "[Settings]\ntool=99\nrenderType=-3\ntheme=1\n"));
|
||||
Settings settings(path);
|
||||
CHECK(settings.tool == Settings{}.tool);
|
||||
CHECK(settings.renderType == Settings{}.renderType);
|
||||
CHECK(settings.theme == 1);
|
||||
std::filesystem::remove(path);
|
||||
}
|
||||
Reference in new issue
Block a user