mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Port of https://github.com/Baystation12/Baystation12/pull/11808 and several others Fixes three overlapping cables ([192 / 158 / 1], [214 / 161 / 1], [122 / 197 / 1]) Fixes drill and mech drill having the same ID.
43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
/datum/unit_test/research_designs_shall_be_unique
|
|
name = "RESEARCH: Designs Shall Be Unique"
|
|
|
|
/datum/unit_test/research_designs_shall_be_unique/start_test()
|
|
var/list/ids = list()
|
|
var/list/build_paths = list()
|
|
|
|
for(var/design_type in typesof(/datum/design) - /datum/design)
|
|
var/datum/design/design = design_type
|
|
if(initial(design.id) == "id")
|
|
continue
|
|
|
|
group_by(ids, design, initial(design.id))
|
|
group_by(build_paths, design, initial(design.build_path))
|
|
|
|
var/number_of_issues = number_of_issues(ids, "IDs")
|
|
number_of_issues += number_of_issues(build_paths, "Build Paths")
|
|
|
|
if(number_of_issues)
|
|
fail("[number_of_issues] issues with research designs found.")
|
|
else
|
|
pass("All research designs are unique.")
|
|
|
|
return 1
|
|
|
|
/datum/unit_test/research_designs_shall_be_unique/proc/group_by(var/list/entries, var/datum/design/entry, var/value)
|
|
var/designs = entries[value]
|
|
if(!designs)
|
|
designs = list()
|
|
entries[value] = designs
|
|
|
|
designs += entry
|
|
|
|
/datum/unit_test/research_designs_shall_be_unique/proc/number_of_issues(var/list/entries, var/type)
|
|
var/issues = 0
|
|
for(var/value in entries)
|
|
var/list/list_of_designs = entries[value]
|
|
if(list_of_designs.len > 1)
|
|
log_unit_test("[type] - The following entries have the same value - [value]: " + english_list(list_of_designs))
|
|
issues++
|
|
|
|
return issues
|