Skip to content

Commit

Permalink
Adds mapping tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerfulBacon committed Aug 24, 2024
1 parent 305bbd2 commit ded19de
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -4098,6 +4098,7 @@
#include "code\modules\tgui_panel\tgui_panel.dm"
#include "code\modules\tooltip\tooltip.dm"
#include "code\modules\unit_tests\_unit_tests.dm"
#include "code\modules\unit_tests\mapping\map_test.dm"
#include "code\modules\uplink\uplink_devices.dm"
#include "code\modules\uplink\uplink_items.dm"
#include "code\modules\uplink\uplink_purchase_log.dm"
Expand Down
38 changes: 38 additions & 0 deletions code/modules/unit_tests/mapping/map_test.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/datum/unit_test/map_test/Run()
var/list/failures
var/list/areas = list()
for (var/z in 1 to world.maxz)
if (!is_station_level(z))
continue
for (var/x in 1 to world.maxx)
for (var/y in 1 to world.maxy)
var/turf/tile = locate(x, y, z)
areas[tile.loc] = TRUE
var/result = check_tile(tile, x == 1 || x == world.maxx || y == 1 || y == world.maxy)
if (result)
LAZYADD(failures, result)
for (var/area/A in areas)
var/result = check_area(A)
if (result)
LAZYADD(failures, result)
if (LAZYLEN(failures))
TEST_FAIL(jointext(failures, "\n"))
for (var/z in 1 to world.maxz)
if (!is_station_level(z))
continue
var/result = check_z_level(z)
if (result)
LAZYADD(failures, result)

/// Return a string if failed, return null otherwise
/datum/unit_test/map_test/proc/check_tile(turf/T, is_map_border)

/// Return a string if failed, return null otherwise
/datum/unit_test/map_test/proc/check_area(area/T)

/// Return a string if failed, return null otherwise
/datum/unit_test/map_test/proc/check_z_level(z_value)

/datum/unit_test/map_test/test/check_tile(turf/T, is_map_border)
if (istype(T, /turf/closed/wall))
return "[T.type] detected"
2 changes: 1 addition & 1 deletion code/modules/unit_tests/unit_test.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GLOBAL_VAR_INIT(focused_tests, focused_tests())

/proc/focused_tests()
var/list/focused_tests = list()
for (var/datum/unit_test/unit_test as anything in subtypesof(/datum/unit_test))
for (var/datum/unit_test/unit_test as anything in subtypesof(/datum/unit_test) - /datum/unit_test/map_test)
if (initial(unit_test.focus))
focused_tests += unit_test

Expand Down

0 comments on commit ded19de

Please sign in to comment.