]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/tests.qc
Provisions for unit testing
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / tests.qc
diff --git a/qcsrc/server/tests.qc b/qcsrc/server/tests.qc
new file mode 100644 (file)
index 0000000..0b153ff
--- /dev/null
@@ -0,0 +1,38 @@
+#include "tests.qh"
+
+void test_weapons_hurt() {
+    SELFPARAM();
+    EXPECT_NE(100, this.health);
+    remove(this.enemy);
+    remove(this);
+}
+
+TEST(Weapons, Hurt)
+{
+    entity it;
+
+    Client a = it = NEW(Client, "A");
+    WITH(float, autocvar_g_spawnshieldtime, 0, Client_Add(it, NUM_TEAM_1));
+    it.origin = '-100 0 0';
+    it.angles = '0 0 0';
+
+    Client b = it = NEW(Client, "B");
+    WITH(float, autocvar_g_spawnshieldtime, 0, Client_Add(it, NUM_TEAM_2));
+    it.origin = '100 0 0';
+    it.angles = '0 180 0';
+
+    it = a;
+    PHYS_INPUT_BUTTON_ATCK(it) = true;
+    it.items |= IT_UNLIMITED_AMMO;
+    Weapon wep = WEP_VORTEX;
+    W_GiveWeapon(it, wep.m_id);
+    W_SwitchWeapon_Force(it, wep);
+
+    it = b;
+    PHYS_INPUT_BUTTON_JUMP(it) = true;
+    it.enemy = a;
+
+    defer(it, wep.switchdelay_raise + 0.1, test_weapons_hurt);
+
+    SUCCEED();
+}