From e97ef2d84d2fac0f454a216a5dc9bda5c6fe0f2c Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 29 Aug 2020 22:58:04 -0700 Subject: [PATCH 1/3] Added a character saving unit test. --- code/modules/unit_tests/_unit_tests.dm | 1 + code/modules/unit_tests/character_saving.dm | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 code/modules/unit_tests/character_saving.dm diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index c739d426c2..e758a43589 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -3,6 +3,7 @@ #ifdef UNIT_TESTS #include "anchored_mobs.dm" +#include "character_saving.dm" #include "component_tests.dm" #include "reagent_id_typos.dm" #include "reagent_recipe_collisions.dm" diff --git a/code/modules/unit_tests/character_saving.dm b/code/modules/unit_tests/character_saving.dm new file mode 100644 index 0000000000..256be59184 --- /dev/null +++ b/code/modules/unit_tests/character_saving.dm @@ -0,0 +1,8 @@ +/datum/unit_test/character_saving/Run() + try + var/datum/preferences/P = new + P.load_path("test") + P.load_character(0) + P.save_character() + catch(exception/e) + Fail("Failed to save and load character due to exception [e.name]") From 3097c790b842b9e78b41531139d749dce1cf7918 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 29 Aug 2020 23:02:18 -0700 Subject: [PATCH 2/3] Added an extra test. --- code/modules/unit_tests/character_saving.dm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/modules/unit_tests/character_saving.dm b/code/modules/unit_tests/character_saving.dm index 256be59184..90767e3393 100644 --- a/code/modules/unit_tests/character_saving.dm +++ b/code/modules/unit_tests/character_saving.dm @@ -2,7 +2,13 @@ try var/datum/preferences/P = new P.load_path("test") - P.load_character(0) + P.features["flavor_text"] = "Foo" + P.features["ooc_notes"] = "Bar" P.save_character() + P.load_character() + if(P.features["flavor_text"] != "Foo") + Fail("Flavor text is failing to save.") + if(P.features["ooc_notes"] != "Bar") + Fail("OOC text is failing to save.") catch(exception/e) Fail("Failed to save and load character due to exception [e.name]") From 66899faa72a39b41edcf42e5fbcfcac55c36d095 Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 29 Aug 2020 23:10:13 -0700 Subject: [PATCH 3/3] needs that var/ --- code/modules/unit_tests/character_saving.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/unit_tests/character_saving.dm b/code/modules/unit_tests/character_saving.dm index 90767e3393..6c83d4142a 100644 --- a/code/modules/unit_tests/character_saving.dm +++ b/code/modules/unit_tests/character_saving.dm @@ -10,5 +10,5 @@ Fail("Flavor text is failing to save.") if(P.features["ooc_notes"] != "Bar") Fail("OOC text is failing to save.") - catch(exception/e) + catch(var/exception/e) Fail("Failed to save and load character due to exception [e.name]")