From 95cb271fee8e25bd2ce789f386cf381a0c74701d Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 1 Jun 2021 04:11:09 +0200 Subject: [PATCH] [MIRROR] Adds a unit test to make sure the right amount of colors are supplied to GAGS configurations (#6048) * Adds a unit test to make sure the right amount of colors are supplied to GAGS configurations * Mirror! Co-authored-by: Emmett Gaines Co-authored-by: Funce --- code/modules/clothing/shoes/miscellaneous.dm | 2 +- code/modules/unit_tests/greyscale_config.dm | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/code/modules/clothing/shoes/miscellaneous.dm b/code/modules/clothing/shoes/miscellaneous.dm index eaea0078cdf..32f9d3ef9ba 100644 --- a/code/modules/clothing/shoes/miscellaneous.dm +++ b/code/modules/clothing/shoes/miscellaneous.dm @@ -1,6 +1,6 @@ /obj/item/clothing/shoes/sneakers/mime name = "mime shoes" - greyscale_colors = "#ffffff" + greyscale_colors = "#ffffff#ffffff" /obj/item/clothing/shoes/combat //basic syndicate combat boots for nuke ops and mob corpses name = "combat boots" diff --git a/code/modules/unit_tests/greyscale_config.dm b/code/modules/unit_tests/greyscale_config.dm index ff7272c3fa7..c576d37a6e9 100644 --- a/code/modules/unit_tests/greyscale_config.dm +++ b/code/modules/unit_tests/greyscale_config.dm @@ -22,3 +22,18 @@ var/belt_icon_state = initial(item_path.belt_icon_state) || initial(item_path.icon_state) if(belt && !belt.icon_states[belt_icon_state]) Fail("[belt.DebugName()] is missing a sprite for the belt overlay for [item_path]. Expected icon state: '[belt_icon_state]'") + +/// Makes sure objects using greyscale configs have, if any, the correct number of colors +/datum/unit_test/greyscale_color_count + +/datum/unit_test/greyscale_color_count/Run() + for(var/atom/thing as anything in subtypesof(/atom)) + var/datum/greyscale_config/config = SSgreyscale.configurations["[initial(thing.greyscale_config)]"] + if(!config) + continue + var/list/colors = splittext(initial(thing.greyscale_colors), "#") + if(!length(colors)) + continue + var/number_of_colors = length(colors) - 1 + if(config.expected_colors != number_of_colors) + Fail("[thing] has the wrong amount of colors configured for [config.DebugName()]. Expected [config.expected_colors] but only found [number_of_colors].")