Skip to content

Commit

Permalink
Add unit test for security levels
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dzianishchyts committed Aug 25, 2024
1 parent 58a588c commit edb4af8
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 6 deletions.
9 changes: 9 additions & 0 deletions code/__DEFINES/_ss220.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#define MODPACK_CHAT_BADGES

#define SEC_LEVEL_GREEN 0
#define SEC_LEVEL_BLUE 1
#define SEC_LEVEL_VIOLET 2
#define SEC_LEVEL_ORANGE 3
#define SEC_LEVEL_RED 4
#define SEC_LEVEL_GAMMA 5
#define SEC_LEVEL_EPSILON 6
#define SEC_LEVEL_DELTA 7

// TODO: someday preferences will use TGUI and you will probably be able to move it to modular_ss220\_defines220\code\preferences_defines.dm
/// Interacts with the toggles220 bitflag
#define PREFTOGGLE_TOGGLE220 220
10 changes: 4 additions & 6 deletions code/__DEFINES/misc_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
//Security levels
#define SEC_LEVEL_GREEN 0

Check warning on line 5 in code/__DEFINES/misc_defines.dm

View workflow job for this annotation

GitHub Actions / Run Linters

macro redefined: SEC_LEVEL_GREEN
#define SEC_LEVEL_BLUE 1

Check warning on line 6 in code/__DEFINES/misc_defines.dm

View workflow job for this annotation

GitHub Actions / Run Linters

macro redefined: SEC_LEVEL_BLUE
#define SEC_LEVEL_VIOLET 2
#define SEC_LEVEL_ORANGE 3
#define SEC_LEVEL_RED 4
#define SEC_LEVEL_GAMMA 5
#define SEC_LEVEL_EPSILON 6
#define SEC_LEVEL_DELTA 7
#define SEC_LEVEL_RED 2

Check warning on line 7 in code/__DEFINES/misc_defines.dm

View workflow job for this annotation

GitHub Actions / Run Linters

macro redefined: SEC_LEVEL_RED
#define SEC_LEVEL_GAMMA 3

Check warning on line 8 in code/__DEFINES/misc_defines.dm

View workflow job for this annotation

GitHub Actions / Run Linters

macro redefined: SEC_LEVEL_GAMMA
#define SEC_LEVEL_EPSILON 4

Check warning on line 9 in code/__DEFINES/misc_defines.dm

View workflow job for this annotation

GitHub Actions / Run Linters

macro redefined: SEC_LEVEL_EPSILON
#define SEC_LEVEL_DELTA 5

Check warning on line 10 in code/__DEFINES/misc_defines.dm

View workflow job for this annotation

GitHub Actions / Run Linters

macro redefined: SEC_LEVEL_DELTA

//Click cooldowns, in tenths of a second
#define CLICK_CD_MELEE 8
Expand Down
5 changes: 5 additions & 0 deletions modular_ss220/modular_ss220.dme
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@
---------------------------------------------------------------------*/

// #include "crit_rework/_crit_rework.dme"

// --- TESTING --- //
#ifdef UNIT_TESTS
#include "unit_tests/_unit_tests.dme"
#endif
4 changes: 4 additions & 0 deletions modular_ss220/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/datum/modpack/unit_tests
name = "Тестирование"
desc = "Здесь тестируется все, что стоит протестировать"
author = "Maxiemar"
3 changes: 3 additions & 0 deletions modular_ss220/unit_tests/_unit_tests.dme
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "_unit_tests.dm"

#include "code/security_levels.dm"
19 changes: 19 additions & 0 deletions modular_ss220/unit_tests/code/security_levels.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/datum/unit_test/security_levels

/datum/unit_test/security_levels/Run()
security_levels_order()

/datum/unit_test/security_levels/proc/security_levels_order()
var/list/expected = list(
new /datum/security_level/green,
new /datum/security_level/blue,
new /datum/security_level/violet,
new /datum/security_level/orange,
new /datum/security_level/red,
new /datum/security_level/gamma,
new /datum/security_level/epsilon,
new /datum/security_level/delta
)
var/list/actual = SSsecurity_level.available_levels
if(!compare_list(expected, actual))
Fail("Security levels order is invalid.\nExpected: [expected]\nActual: [actual]")

0 comments on commit edb4af8

Please sign in to comment.