Xonotic
tests.qc File Reference
#include "tests.qh"
+ Include dependency graph for tests.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 TEST (Weapons, Hurt)
 
 TEST (Vehicles, Spawn)
 
void test_weapons_hurt (entity this)
 

Function Documentation

◆ TEST() [1/2]

TEST ( Weapons  ,
Hurt   
)

Definition at line 10 of file tests.qc.

References autocvar_g_spawnshieldtime, entity(), Weapon::m_id, NEW, NUM_TEAM_1, NUM_TEAM_2, PHYS_INPUT_BUTTON_ATCK, PHYS_INPUT_BUTTON_JUMP, SUCCEED, test_weapons_hurt(), W_GiveWeapon(), W_SwitchWeapon_Force(), weaponentities, and WITH.

11 {
12  entity it;
13 
14  noref Client a = it = NEW(Client, "A");
15  WITH(float, autocvar_g_spawnshieldtime, 0, Client_Add(it, NUM_TEAM_1));
16  it.origin = '-100 0 0';
17  it.angles = '0 0 0';
18 
19  noref Client b = it = NEW(Client, "B");
20  WITH(float, autocvar_g_spawnshieldtime, 0, Client_Add(it, NUM_TEAM_2));
21  it.origin = '100 0 0';
22  it.angles = '0 180 0';
23 
24  it = a;
25  PHYS_INPUT_BUTTON_ATCK(it) = true;
26  it.items |= IT_UNLIMITED_AMMO;
27  Weapon wep = WEP_VORTEX;
28  W_GiveWeapon(it, wep.m_id);
30 
31  it = b;
32  PHYS_INPUT_BUTTON_JUMP(it) = true;
33  it.enemy = a;
34 
35  defer(it, wep.switchdelay_raise + 0.1, test_weapons_hurt);
36 
37  SUCCEED();
38 }
#define PHYS_INPUT_BUTTON_JUMP(s)
Definition: player.qh:147
const int NUM_TEAM_2
Definition: teams.qh:19
void W_SwitchWeapon_Force(Player this, Weapon w,.entity weaponentity)
Definition: selection.qc:243
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
#define SUCCEED()
Must be present at the end of a test.
Definition: test.qh:15
void W_GiveWeapon(entity e, int wep)
Definition: common.qc:33
void test_weapons_hurt(entity this)
Definition: tests.qc:3
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition: player.qh:146
Definition: client.qh:88
#define WITH(type, name, value, block)
Definition: misc.qh:40
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
const int NUM_TEAM_1
Definition: teams.qh:18
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
float autocvar_g_spawnshieldtime
Definition: player.qh:3
int m_id
Definition: weapon.qh:42
+ Here is the call graph for this function:

◆ TEST() [2/2]

TEST ( Vehicles  ,
Spawn   
)

Definition at line 40 of file tests.qc.

References ACTIVE_NOT, entity(), NEW, NUM_TEAM_1, SUCCEED, time, v, vehicle, and vehicle_initialize().

41 {
42  entity it;
43 
44  noref Client bot = it = NEW(Client, "Rider");
45  Client_Add(it, NUM_TEAM_1);
46  it.origin = '0 0 100';
47 
48  noref entity v = it = new(vehicle);
49  Vehicle veh = VEH_BUMBLEBEE;
50  it.active = ACTIVE_NOT;
51  vehicle_initialize(it, veh, false);
52  it.nextthink = time;
53 
54  SUCCEED();
55 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
#define SUCCEED()
Must be present at the end of a test.
Definition: test.qh:15
Definition: client.qh:88
vector v
Definition: ent_cs.qc:116
const int NUM_TEAM_1
Definition: teams.qh:18
entity vehicle
Definition: impulse.qc:21
const int ACTIVE_NOT
Definition: defs.qh:36
float time
Definition: csprogsdefs.qc:16
bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
+ Here is the call graph for this function:

◆ test_weapons_hurt()

void test_weapons_hurt ( entity  this)

Definition at line 3 of file tests.qc.

References enemy, EXPECT_NE, GetResource(), and RES_HEALTH.

Referenced by TEST().

4 {
5  EXPECT_NE(100, GetResource(this, RES_HEALTH));
6  delete(this.enemy);
7  delete(this);
8 }
#define EXPECT_NE(val1, val2)
Definition: test.qh:52
RES_HEALTH
Definition: ent_cs.qc:126
entity enemy
Definition: sv_ctf.qh:143
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function: