Skip to content

Commit

Permalink
Added missing tests for magazine functions
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Mar 31, 2024
1 parent 4a82c74 commit 64c04b9
Showing 1 changed file with 75 additions and 7 deletions.
82 changes: 75 additions & 7 deletions addons/common/test_inventory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,41 @@ LOG("Testing " + _funcName);

TEST_DEFINED("CBA_fnc_addMagazine","");

_result = [objNull, "SmokeShell"] call CBA_fnc_addMagazine;
_result = [objNull, "30Rnd_556x45_Stanag"] call CBA_fnc_addMagazine;
TEST_FALSE(_result,_funcName);

_result = [player, ""] call CBA_fnc_addMagazine;
TEST_FALSE(_result,_funcName);

_result = [player, "SmokeShell"] call CBA_fnc_addMagazine;
_result = [player, "30Rnd_556x45_Stanag"] call CBA_fnc_addMagazine;
TEST_TRUE(_result,_funcName);

_result = [player, "30Rnd_556x45_Stanag", 1, true] call CBA_fnc_addMagazine;
TEST_TRUE(_result,_funcName);

_result = [player, "30Rnd_556x45_Stanag", 1, true] call CBA_fnc_addMagazine;
TEST_TRUE(_result,_funcName);

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

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

_result = [objNull, "SmokeShell"] call CBA_fnc_removeMagazine;
_result = [objNull, "30Rnd_556x45_Stanag"] call CBA_fnc_removeMagazine;
TEST_FALSE(_result,_funcName);

_result = [player, ""] call CBA_fnc_removeMagazine;
TEST_FALSE(_result,_funcName);

_result = [player, "SmokeShell"] call CBA_fnc_removeMagazine;
_result = [player, "30Rnd_556x45_Stanag"] call CBA_fnc_removeMagazine;
TEST_TRUE(_result,_funcName);

_result = [player, "30Rnd_556x45_Stanag", 1] call CBA_fnc_removeMagazine;
TEST_TRUE(_result,_funcName);

player removeMagazines "SmokeShell";
player removeMagazines "30Rnd_556x45_Stanag";

_result = [player, "SmokeShell"] call CBA_fnc_removeMagazine;
_result = [player, "30Rnd_556x45_Stanag"] call CBA_fnc_removeMagazine;
TEST_FALSE(_result,_funcName);

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -160,10 +169,69 @@ TEST_TRUE(count (itemCargo _container) == 5,_funcName);
clearItemCargoGlobal _container;


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

_result = [objNull, "30Rnd_556x45_Stanag"] call CBA_fnc_removeMagazine;
TEST_FALSE(_result,_funcName);

_result = [_container, ""] call CBA_fnc_removeMagazine;
TEST_FALSE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag"] call CBA_fnc_removeMagazine;
TEST_FALSE(_result,_funcName);

_container addMagazineAmmoCargo ["30Rnd_556x45_Stanag", 2, 1];

_result = [_container, "30Rnd_556x45_Stanag"] call CBA_fnc_removeMagazine;
TEST_TRUE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag", 2] call CBA_fnc_removeMagazine;
TEST_FALSE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag", 1] call CBA_fnc_removeMagazine;
TEST_TRUE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag"] call CBA_fnc_removeMagazine;
TEST_FALSE(_result,_funcName);


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

_result = [objNull, "30Rnd_556x45_Stanag"] call CBA_fnc_addMagazineCargo;
TEST_FALSE(_result,_funcName);

_result = [_container, ""] call CBA_fnc_addMagazineCargo;
TEST_FALSE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag", 5] call CBA_fnc_addMagazineCargo;
TEST_TRUE(_result,_funcName);
TEST_TRUE(count (magazineCargo _container) == 5,_funcName);

_result = [_container, "30Rnd_556x45_Stanag", 1000, false, 1] call CBA_fnc_addMagazineCargo;
TEST_FALSE(_result,_funcName);


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

_result = [objNull, "SmokeShell"] call CBA_fnc_removeMagazineCargo;
_result = [objNull, "30Rnd_556x45_Stanag"] call CBA_fnc_removeMagazineCargo;
TEST_FALSE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag"] call CBA_fnc_removeMagazineCargo;
TEST_TRUE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag", 2] call CBA_fnc_removeMagazineCargo;
TEST_TRUE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag", 1, 2] call CBA_fnc_removeMagazineCargo;
TEST_FALSE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag", 1, 1] call CBA_fnc_removeMagazineCargo;
TEST_FALSE(_result,_funcName);

_result = [_container, "30Rnd_556x45_Stanag", 1000] call CBA_fnc_removeMagazineCargo;
TEST_FALSE(_result,_funcName);

_container addMagazineCargoGlobal ["30Rnd_556x45_Stanag", 5];
Expand Down

0 comments on commit 64c04b9

Please sign in to comment.