Skip to content

Commit

Permalink
Merge pull request #602 from CBATeam/fix-getPos
Browse files Browse the repository at this point in the history
fix CBA_fnc_getPos
  • Loading branch information
Killswitch00 authored Feb 25, 2017
2 parents 84a5238 + 42a9270 commit 3108941
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addons/common/fnc_getPos.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ switch (typeName _entity) do {
case "ARRAY": {
+ _entity
};
case "NUMBER": { // in case of position being passed not in array
case "SCALAR": { // in case of position being passed not in array
+ _this
};
};
2 changes: 1 addition & 1 deletion addons/common/test.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"

#define TESTS ["config", "inventory", "weaponComponents", "ret", "macro_is_x"]
#define TESTS ["config", "inventory", "weaponComponents", "position", "ret", "macro_is_x"]

SCRIPT(test-common);

Expand Down
64 changes: 64 additions & 0 deletions addons/common/test_position.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "script_component.hpp"
SCRIPT(test_position);

// execVM "\x\cba\addons\common\test_position.sqf";

private ["_funcName", "_value", "_result"];

_funcName = "CBA_fnc_getPos";
LOG("Testing " + _funcName);

TEST_DEFINED(_funcName,"");

_value = objNull;
_result = _value call CBA_fnc_getPos;

#define EXPECTED [0,0,0]
TEST_TRUE(_result isEqualTo EXPECTED,_funcName);

////////////////////////////////////////////////////////////////////////////////////////////////////

_value = grpNull;
_result = _value call CBA_fnc_getPos;

TEST_TRUE(_result isEqualTo EXPECTED,_funcName);

////////////////////////////////////////////////////////////////////////////////////////////////////

_value = ""; // marker
_result = _value call CBA_fnc_getPos;

TEST_TRUE(_result isEqualTo EXPECTED,_funcName);

////////////////////////////////////////////////////////////////////////////////////////////////////

_value = locationNull;
_result = _value call CBA_fnc_getPos;

TEST_TRUE(_result isEqualTo EXPECTED,_funcName);

////////////////////////////////////////////////////////////////////////////////////////////////////

#define EXPECTED [1,2,0] // Pos 3D

_value = EXPECTED;
_result = _value call CBA_fnc_getPos;

// confirm that input array is copied
_value set [0,-1];

TEST_TRUE(_result isEqualTo EXPECTED,_funcName);

////////////////////////////////////////////////////////////////////////////////////////////////////

#define EXPECTED [1,2] // Pos 2D

_value = EXPECTED;
_result = _value call CBA_fnc_getPos;

// confirm that input array is copied
_value set [0,-1];

TEST_TRUE(_result isEqualTo EXPECTED,_funcName);

////////////////////////////////////////////////////////////////////////////////////////////////////

0 comments on commit 3108941

Please sign in to comment.