diff --git a/Semesterprojekt/src/test/java/thb/jeanluc/adventure/save/SettingsStoreTest.java b/Semesterprojekt/src/test/java/thb/jeanluc/adventure/save/SettingsStoreTest.java index 8b959d0..9cca9fd 100644 --- a/Semesterprojekt/src/test/java/thb/jeanluc/adventure/save/SettingsStoreTest.java +++ b/Semesterprojekt/src/test/java/thb/jeanluc/adventure/save/SettingsStoreTest.java @@ -4,6 +4,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import thb.jeanluc.adventure.io.ConsoleIO; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import static org.assertj.core.api.Assertions.assertThat; @@ -24,4 +26,12 @@ class SettingsStoreTest { Settings loaded = new SettingsStore(dir.resolve("nope.json")).load(); assertThat(loaded).isEqualTo(Settings.defaults()); } + + @Test + void corruptFileReturnsDefaults(@TempDir Path dir) throws IOException { + Path file = dir.resolve("settings.json"); + Files.writeString(file, "{ not json"); + Settings loaded = new SettingsStore(file).load(); + assertThat(loaded).isEqualTo(Settings.defaults()); + } }