Skip to content

Commit

Permalink
Adds an implanting unit test (#13691)
Browse files Browse the repository at this point in the history
* Adds an implanting unit test

* Update implanting.dm

* Update implanter.dm
  • Loading branch information
Xander3359 authored Aug 13, 2023
1 parent b370eda commit ea9219b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion code/game/objects/items/implants/implanter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
log_game(user, target, "implanted", src)
imp = null
update_icon()
return
return TRUE
to_chat(user, span_notice(" You fail to implant [target]."))

/obj/item/implanter/neurostim
Expand Down
1 change: 1 addition & 0 deletions code/modules/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "component_tests.dm"
#include "connect_loc.dm"
#include "dcs_get_id_from_elements.dm"
#include "implanting.dm"
#include "initialize_sanity.dm"
#include "keybinding_init.dm"
#include "map_templates.dm"
Expand Down
16 changes: 16 additions & 0 deletions code/modules/unit_tests/implanting.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
///Implants a human to make sure it effectively is inserted and deleted.
/datum/unit_test/implanting

/datum/unit_test/implanting/Run()
var/mob/living/carbon/human/implanted_guy = allocate(/mob/living/carbon/human)
var/obj/item/implanter/implanter_to_inject = allocate(/obj/item/implanter/cloak)

var/obj/item/implant/implant_in_planter = implanter_to_inject.imp

implanted_guy.put_in_active_hand(implanter_to_inject)

TEST_ASSERT(implanter_to_inject.attack(implanted_guy, implanted_guy), "[implanted_guy] failed to inject himself with [implanter_to_inject]")
TEST_ASSERT(!implanter_to_inject.imp, "[implanter_to_inject] still has an implant in its implanter, despite being injected into [implanted_guy]")

qdel(implanted_guy)
TEST_ASSERT(QDELETED(implant_in_planter), "[implant_in_planter] has been injected into [implanted_guy], who has been deleted, but the implant still exists.")

0 comments on commit ea9219b

Please sign in to comment.