mirror of
https://github.com/TheOnlyZac/sly1.git
synced 2024-11-27 07:30:26 +00:00
Test updates
This commit is contained in:
parent
846e4223b1
commit
a9f33a5d01
@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
// Custom assert function that doesn't call abort
|
|
||||||
inline void assert(bool assertion)
|
|
||||||
{
|
|
||||||
if (!assertion)
|
|
||||||
{
|
|
||||||
printf("Assertion failed");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +1,23 @@
|
|||||||
#include <clock.h>
|
#include <clock.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
SetClockRate(1.0);
|
SetClockRate(1.0);
|
||||||
assert(g_rtClock == 1.0f);
|
JtAssert(g_rtClock == 1.0f);
|
||||||
assert(g_clock.fEnabled == true);
|
JtAssert(g_clock.fEnabled);
|
||||||
|
|
||||||
SetClockRate(0.5);
|
SetClockRate(0.5);
|
||||||
assert(g_rtClock == 0.5f);
|
JtAssert(g_rtClock == 0.5f);
|
||||||
assert(g_clock.fEnabled == true);
|
JtAssert(g_clock.fEnabled);
|
||||||
|
|
||||||
SetClockRate(0);
|
SetClockRate(0);
|
||||||
assert(g_rtClock == 0.f);
|
JtAssert(g_rtClock == 0.f);
|
||||||
assert(g_clock.fEnabled == false);
|
JtAssert(!g_clock.fEnabled);
|
||||||
|
|
||||||
SetClockRate(-1);
|
SetClockRate(-1);
|
||||||
assert(g_rtClock == -1.f);
|
JtAssert(g_rtClock == -1.f);
|
||||||
assert(g_clock.fEnabled == false);
|
JtAssert(!g_clock.fEnabled);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <coin.h>
|
#include <coin.h>
|
||||||
#include <gs.h>
|
#include <gs.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -11,20 +11,20 @@ int main()
|
|||||||
g_pgsCur->ccharm = 0;
|
g_pgsCur->ccharm = 0;
|
||||||
OnCoinSmack(&coin);
|
OnCoinSmack(&coin);
|
||||||
|
|
||||||
assert(g_pgsCur->ccoin == 1);
|
JtAssert(g_pgsCur->ccoin == 1);
|
||||||
assert(g_pgsCur->ccharm == 0);
|
JtAssert(g_pgsCur->ccharm == 0);
|
||||||
|
|
||||||
g_pgsCur->ccoin = 98;
|
g_pgsCur->ccoin = 98;
|
||||||
OnCoinSmack(&coin);
|
OnCoinSmack(&coin);
|
||||||
|
|
||||||
assert(g_pgsCur->ccoin == 99);
|
JtAssert(g_pgsCur->ccoin == 99);
|
||||||
assert(g_pgsCur->ccharm == 0);
|
JtAssert(g_pgsCur->ccharm == 0);
|
||||||
|
|
||||||
// Test collecting a 100 coins to get a charm
|
// Test collecting a 100 coins to get a charm
|
||||||
OnCoinSmack(&coin);
|
OnCoinSmack(&coin);
|
||||||
|
|
||||||
assert(g_pgsCur->ccoin == 0);
|
JtAssert(g_pgsCur->ccoin == 0);
|
||||||
assert(g_pgsCur->ccharm == 1);
|
JtAssert(g_pgsCur->ccharm == 1);
|
||||||
|
|
||||||
// Test collecting 100 coins to get an extra life
|
// Test collecting 100 coins to get an extra life
|
||||||
g_pgsCur->ccoin = 99;
|
g_pgsCur->ccoin = 99;
|
||||||
@ -32,9 +32,9 @@ int main()
|
|||||||
g_pgsCur->clife = 5;
|
g_pgsCur->clife = 5;
|
||||||
OnCoinSmack(&coin);
|
OnCoinSmack(&coin);
|
||||||
|
|
||||||
assert(g_pgsCur->ccoin == 0);
|
JtAssert(g_pgsCur->ccoin == 0);
|
||||||
assert(g_pgsCur->ccharm == 2);
|
JtAssert(g_pgsCur->ccharm == 2);
|
||||||
assert(g_pgsCur->clife == 6);
|
JtAssert(g_pgsCur->clife == 6);
|
||||||
|
|
||||||
// Test collecting a coin when coins, lives, and charms are all at max
|
// Test collecting a coin when coins, lives, and charms are all at max
|
||||||
g_pgsCur->ccoin = 99;
|
g_pgsCur->ccoin = 99;
|
||||||
@ -42,7 +42,7 @@ int main()
|
|||||||
g_pgsCur->clife = 99;
|
g_pgsCur->clife = 99;
|
||||||
OnCoinSmack(&coin);
|
OnCoinSmack(&coin);
|
||||||
|
|
||||||
assert(g_pgsCur->ccoin == 99);
|
JtAssert(g_pgsCur->ccoin == 99);
|
||||||
assert(g_pgsCur->ccharm == 2);
|
JtAssert(g_pgsCur->ccharm == 2);
|
||||||
assert(g_pgsCur->clife == 99);
|
JtAssert(g_pgsCur->clife == 99);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <difficulty.h>
|
#include <difficulty.h>
|
||||||
#include <gs.h>
|
#include <gs.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -10,19 +10,19 @@ int main()
|
|||||||
OnDifficultyWorldPostLoad(&g_difficulty);
|
OnDifficultyWorldPostLoad(&g_difficulty);
|
||||||
|
|
||||||
// Test changing level suck
|
// Test changing level suck
|
||||||
g_plsCur->uSuck = 0.0;
|
g_plsCur->uSuck = 0.0f;
|
||||||
assert(g_plsCur->uSuck == 0.0);
|
JtAssert(g_plsCur->uSuck == 0.0f);
|
||||||
|
|
||||||
ChangeSuck(0.1, &g_difficulty);
|
ChangeSuck(0.1, &g_difficulty);
|
||||||
assert(g_plsCur->uSuck == 0.1);
|
JtAssert(g_plsCur->uSuck == 0.1f);
|
||||||
|
|
||||||
ChangeSuck(1.0, &g_difficulty);
|
ChangeSuck(1.0, &g_difficulty);
|
||||||
assert(g_plsCur->uSuck == 1.0);
|
JtAssert(g_plsCur->uSuck == 1.0f);
|
||||||
|
|
||||||
ChangeSuck(-1.0, &g_difficulty);
|
ChangeSuck(-1.0, &g_difficulty);
|
||||||
assert(g_plsCur->uSuck == -1.0);
|
JtAssert(g_plsCur->uSuck == -1.0f);
|
||||||
|
|
||||||
// Test collect key scenario
|
// Test collect key scenario
|
||||||
OnDifficultyCollectKey(&g_difficulty);
|
OnDifficultyCollectKey(&g_difficulty);
|
||||||
assert(g_plsCur->uSuck == 0.0);
|
JtAssert(g_plsCur->uSuck == 0.0f);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <difficulty.h>
|
#include <difficulty.h>
|
||||||
#include <gs.h>
|
#include <gs.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
void SetGameLevel(GAMEWORLD gameworld, WORLDLEVEL worldlevel);
|
void SetGameLevel(GAMEWORLD gameworld, WORLDLEVEL worldlevel);
|
||||||
|
|
||||||
@ -13,13 +13,13 @@ int main()
|
|||||||
// jb_intro = easy
|
// jb_intro = easy
|
||||||
SetGameLevel(GAMEWORLD::Intro, WORLDLEVEL::Approach);
|
SetGameLevel(GAMEWORLD::Intro, WORLDLEVEL::Approach);
|
||||||
OnDifficultyWorldPreLoad(&g_difficulty);
|
OnDifficultyWorldPreLoad(&g_difficulty);
|
||||||
assert(g_difficulty.props == &g_difficultyEasy);
|
JtAssert(g_difficulty.props == &g_difficultyEasy);
|
||||||
|
|
||||||
|
|
||||||
// cw_security = easy
|
// cw_security = easy
|
||||||
SetGameLevel(GAMEWORLD::Clockwerk, WORLDLEVEL::Level2);
|
SetGameLevel(GAMEWORLD::Clockwerk, WORLDLEVEL::Level2);
|
||||||
OnDifficultyWorldPreLoad(&g_difficulty);
|
OnDifficultyWorldPreLoad(&g_difficulty);
|
||||||
assert(g_difficulty.props == &g_difficultyEasy);
|
JtAssert(g_difficulty.props == &g_difficultyEasy);
|
||||||
|
|
||||||
|
|
||||||
// uw_bonus_security
|
// uw_bonus_security
|
||||||
@ -28,12 +28,12 @@ int main()
|
|||||||
// no key = medium
|
// no key = medium
|
||||||
g_plsCur->fls = static_cast<FLS>((int)g_plsCur->fls & ~(int)FLS::KeyCollected); // unset KeyCollected flag
|
g_plsCur->fls = static_cast<FLS>((int)g_plsCur->fls & ~(int)FLS::KeyCollected); // unset KeyCollected flag
|
||||||
OnDifficultyWorldPreLoad(&g_difficulty);
|
OnDifficultyWorldPreLoad(&g_difficulty);
|
||||||
assert(g_difficulty.props == &g_difficultyMedium);
|
JtAssert(g_difficulty.props == &g_difficultyMedium);
|
||||||
|
|
||||||
// with key = hard
|
// with key = hard
|
||||||
g_plsCur->fls = static_cast<FLS>((int)g_plsCur->fls | (int)FLS::KeyCollected); // setKeyCollected flag
|
g_plsCur->fls = static_cast<FLS>((int)g_plsCur->fls | (int)FLS::KeyCollected); // setKeyCollected flag
|
||||||
OnDifficultyWorldPreLoad(&g_difficulty);
|
OnDifficultyWorldPreLoad(&g_difficulty);
|
||||||
assert(g_difficulty.props == &g_difficultyHard);
|
JtAssert(g_difficulty.props == &g_difficultyHard);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <game.h>
|
#include <game.h>
|
||||||
#include <joy.h>
|
#include <joy.h>
|
||||||
#include <gs.h>
|
#include <gs.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -9,34 +9,34 @@ int main()
|
|||||||
g_grfcht &= ~((int)FCHT::InfiniteCharms); // disable infinite charms
|
g_grfcht &= ~((int)FCHT::InfiniteCharms); // disable infinite charms
|
||||||
|
|
||||||
// Confirm max charm count is 2
|
// Confirm max charm count is 2
|
||||||
assert(CcharmMost() == 2);
|
JtAssert(CcharmMost() == 2);
|
||||||
|
|
||||||
// Test checking if a charm is available
|
// Test checking if a charm is available
|
||||||
g_pgsCur->ccharm = 0;
|
g_pgsCur->ccharm = 0;
|
||||||
assert(FCharmAvailable() == false);
|
JtAssert(FCharmAvailable() == false);
|
||||||
|
|
||||||
g_pgsCur->ccharm = 1;
|
g_pgsCur->ccharm = 1;
|
||||||
assert(FCharmAvailable() == true);
|
JtAssert(FCharmAvailable() == true);
|
||||||
|
|
||||||
g_pgsCur->ccharm = -1;
|
g_pgsCur->ccharm = -1;
|
||||||
assert(FCharmAvailable() == false);
|
JtAssert(FCharmAvailable() == false);
|
||||||
|
|
||||||
g_pgsCur->ccharm = 0;
|
g_pgsCur->ccharm = 0;
|
||||||
g_grfcht |= (int)FCHT::InfiniteCharms; // enable infinite charms cheat
|
g_grfcht |= (int)FCHT::InfiniteCharms; // enable infinite charms cheat
|
||||||
assert(FCharmAvailable() == true);
|
JtAssert(FCharmAvailable() == true);
|
||||||
|
|
||||||
// Test setting charm count
|
// Test setting charm count
|
||||||
SetCcharm(0);
|
SetCcharm(0);
|
||||||
assert(g_pgsCur->ccharm == 0);
|
JtAssert(g_pgsCur->ccharm == 0);
|
||||||
|
|
||||||
SetCcharm(1);
|
SetCcharm(1);
|
||||||
assert(g_pgsCur->ccharm == 1);
|
JtAssert(g_pgsCur->ccharm == 1);
|
||||||
|
|
||||||
SetCcharm(3);
|
SetCcharm(3);
|
||||||
assert(g_pgsCur->ccharm == 3);
|
JtAssert(g_pgsCur->ccharm == 3);
|
||||||
|
|
||||||
SetCcharm(-1);
|
SetCcharm(-1);
|
||||||
assert(g_pgsCur->ccharm == -1);
|
JtAssert(g_pgsCur->ccharm == -1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
#include <game.h>
|
#include <game.h>
|
||||||
#include <joy.h>
|
#include <joy.h>
|
||||||
#include <gs.h>
|
#include <gs.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Confirm max charm count is 2
|
// Confirm max charm count is 2
|
||||||
assert(CcharmMost() == 2);
|
JtAssert(CcharmMost() == 2);
|
||||||
|
|
||||||
// Test setting charm count
|
// Test setting charm count
|
||||||
SetCcharm(0);
|
SetCcharm(0);
|
||||||
assert(g_pgsCur->ccharm == 0);
|
JtAssert(g_pgsCur->ccharm == 0);
|
||||||
|
|
||||||
SetCcharm(1);
|
SetCcharm(1);
|
||||||
assert(g_pgsCur->ccharm == 1);
|
JtAssert(g_pgsCur->ccharm == 1);
|
||||||
|
|
||||||
SetCcharm(3);
|
SetCcharm(3);
|
||||||
assert(g_pgsCur->ccharm == 3);
|
JtAssert(g_pgsCur->ccharm == 3);
|
||||||
|
|
||||||
SetCcharm(-1);
|
SetCcharm(-1);
|
||||||
assert(g_pgsCur->ccharm == -1);
|
JtAssert(g_pgsCur->ccharm == -1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <game.h>
|
#include <game.h>
|
||||||
#include <joy.h>
|
#include <joy.h>
|
||||||
#include <gs.h>
|
#include <gs.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -10,19 +10,19 @@ int main()
|
|||||||
|
|
||||||
// Test setting coin count
|
// Test setting coin count
|
||||||
SetCcoin(0);
|
SetCcoin(0);
|
||||||
assert(g_pgsCur->ccoin == 0);
|
JtAssert(g_pgsCur->ccoin == 0);
|
||||||
|
|
||||||
SetCcoin(14);
|
SetCcoin(14);
|
||||||
assert(g_pgsCur->ccoin == 14);
|
JtAssert(g_pgsCur->ccoin == 14);
|
||||||
|
|
||||||
SetCcoin(99);
|
SetCcoin(99);
|
||||||
assert(g_pgsCur->ccoin == 99);
|
JtAssert(g_pgsCur->ccoin == 99);
|
||||||
|
|
||||||
SetCcoin(-1);
|
SetCcoin(-1);
|
||||||
assert(g_pgsCur->ccoin == -1);
|
JtAssert(g_pgsCur->ccoin == -1);
|
||||||
|
|
||||||
SetCcoin(101);
|
SetCcoin(101);
|
||||||
assert(g_pgsCur->ccoin == 101);
|
JtAssert(g_pgsCur->ccoin == 101);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
#include <gs.h>
|
#include <gs.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include "../test.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -8,7 +8,7 @@ int main()
|
|||||||
|
|
||||||
// Test save file percent calculation
|
// Test save file percent calculation
|
||||||
int percent = CalculatePercentCompletion(g_pgsCur);
|
int percent = CalculatePercentCompletion(g_pgsCur);
|
||||||
assert(percent == 0);
|
JtAssert(percent == 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <joy.h>
|
#include <joy.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -7,16 +7,16 @@ int main()
|
|||||||
g_grfcht = 0x0;
|
g_grfcht = 0x0;
|
||||||
|
|
||||||
AddFcht((int)FCHT::InfiniteCharms);
|
AddFcht((int)FCHT::InfiniteCharms);
|
||||||
assert(g_grfcht == 0x2);
|
JtAssert(g_grfcht == 0x2);
|
||||||
|
|
||||||
AddFcht((int)FCHT::LowGravity);
|
AddFcht((int)FCHT::LowGravity);
|
||||||
assert(g_grfcht == 0x6);
|
JtAssert(g_grfcht == 0x6);
|
||||||
|
|
||||||
AddFcht((int)FCHT::Invulnerability);
|
AddFcht((int)FCHT::Invulnerability);
|
||||||
assert(g_grfcht == 0x7);
|
JtAssert(g_grfcht == 0x7);
|
||||||
|
|
||||||
AddFcht((int)FCHT::LowFriction);
|
AddFcht((int)FCHT::LowFriction);
|
||||||
assert(g_grfcht == 0xF);
|
JtAssert(g_grfcht == 0xF);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
#include <joy.h>
|
#include <joy.h>
|
||||||
#include <gs.h>
|
#include <gs.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@ -13,12 +13,12 @@ int main()
|
|||||||
g_pgsCur->clife = 0;
|
g_pgsCur->clife = 0;
|
||||||
|
|
||||||
CheatActivateChetkido();
|
CheatActivateChetkido();
|
||||||
assert(strstr(chetkido_buffer, "The password is: chetkido") != NULL);
|
JtAssert(strstr(chetkido_buffer, "The password is: chetkido") != NULL);
|
||||||
|
|
||||||
g_pgsCur->ccoin = 98;
|
g_pgsCur->ccoin = 98;
|
||||||
|
|
||||||
CheatActivateChetkido();
|
CheatActivateChetkido();
|
||||||
assert(strstr(chetkido_buffer, "The password is: chetkido") == NULL);
|
JtAssert(strstr(chetkido_buffer, "The password is: chetkido") == NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
22
test/test.h
Normal file
22
test/test.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||||
|
|
||||||
|
// Custom assert macro that doesn't call abort
|
||||||
|
#define JtAssert(assertion) \
|
||||||
|
{ \
|
||||||
|
if (!(assertion)) \
|
||||||
|
{ \
|
||||||
|
printf( \
|
||||||
|
"\nAn assertion failure has occurred\n" \
|
||||||
|
"========================================\n" \
|
||||||
|
"Assertion: %s\n" \
|
||||||
|
"File: %s\nLine %d, in %s\n" \
|
||||||
|
"========================================\n\n", \
|
||||||
|
#assertion, __FILENAME__, __LINE__, __FUNCTION__); \
|
||||||
|
exit(1); \
|
||||||
|
} \
|
||||||
|
}
|
@ -1,32 +1,35 @@
|
|||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
|
// disable warning for truncating double to float
|
||||||
|
#pragma warning(disable: 4305)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Clamp value between -1 and 1
|
// Clamp value between -1 and 1
|
||||||
assert(GLimitAbs(-5, 1) == -1.f);
|
JtAssert(GLimitAbs(-5, 1) == -1.f);
|
||||||
assert(GLimitAbs(-1, 1) == -1.f);
|
JtAssert(GLimitAbs(-1, 1) == -1.f);
|
||||||
assert(GLimitAbs(-0.4, 1) == -0.4f);
|
JtAssert(GLimitAbs(-0.4, 1) == -0.4f);
|
||||||
assert(GLimitAbs(0.76, 1) == 0.76f);
|
JtAssert(GLimitAbs(0.76, 1) == 0.76f);
|
||||||
assert(GLimitAbs(1, 1) == 1.f);
|
JtAssert(GLimitAbs(1, 1) == 1.f);
|
||||||
assert(GLimitAbs(17, 1) == 1.f);
|
JtAssert(GLimitAbs(17, 1) == 1.f);
|
||||||
|
|
||||||
// Clamp value between -3.14 and 3.14
|
// Clamp value between -3.14 and 3.14
|
||||||
assert(GLimitAbs(-5, 3.14) == -3.14f);
|
JtAssert(GLimitAbs(-5, 3.14) == -3.14f);
|
||||||
assert(GLimitAbs(-1, 3.14) == -1.f);
|
JtAssert(GLimitAbs(-1, 3.14) == -1.f);
|
||||||
assert(GLimitAbs(-0.4, 3.14) == -0.4f);
|
JtAssert(GLimitAbs(-0.4, 3.14) == -0.4f);
|
||||||
assert(GLimitAbs(0.76, 3.14) == 0.76f);
|
JtAssert(GLimitAbs(0.76, 3.14) == 0.76f);
|
||||||
assert(GLimitAbs(3.14, 3.14) == 3.14f);
|
JtAssert(GLimitAbs(3.14, 3.14) == 3.14f);
|
||||||
assert(GLimitAbs(17, 3.14) == 3.14f);
|
JtAssert(GLimitAbs(17, 3.14) == 3.14f);
|
||||||
|
|
||||||
// Clamp value between -100 and 100
|
// Clamp value between -100 and 100
|
||||||
assert(GLimitAbs(-1000, 100) == -100.f);
|
JtAssert(GLimitAbs(-1000, 100) == -100.f);
|
||||||
assert(GLimitAbs(-100, 100) == -100.f);
|
JtAssert(GLimitAbs(-100, 100) == -100.f);
|
||||||
assert(GLimitAbs(-17.3, 100) == -17.3f);
|
JtAssert(GLimitAbs(-17.3, 100) == -17.3f);
|
||||||
assert(GLimitAbs(0, 100) == 0.f);
|
JtAssert(GLimitAbs(0, 100) == 0.f);
|
||||||
assert(GLimitAbs(91, 100) == 91.f);
|
JtAssert(GLimitAbs(91, 100) == 91.f);
|
||||||
assert(GLimitAbs(100.2, 100) == 100.f);
|
JtAssert(GLimitAbs(100.2, 100) == 100.f);
|
||||||
assert(GLimitAbs(420.69, 100) == 100.f);
|
JtAssert(GLimitAbs(420.69, 100) == 100.f);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include "../assert.h"
|
#include "../test.h"
|
||||||
|
|
||||||
|
#pragma warning(disable: 4305)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Clamp value using global 0-1 limit
|
// Clamp value using global 0-1 limit
|
||||||
assert(GLimitLm(&g_lmZeroOne, -2.3) == 0.f);
|
JtAssert(GLimitLm(&g_lmZeroOne, -2.3) == 0.f);
|
||||||
assert(GLimitLm(&g_lmZeroOne, 0) == 0.f);
|
JtAssert(GLimitLm(&g_lmZeroOne, 0) == 0.f);
|
||||||
assert(GLimitLm(&g_lmZeroOne, 0.234) == 0.234f);
|
JtAssert(GLimitLm(&g_lmZeroOne, 0.234) == 0.234f);
|
||||||
assert(GLimitLm(&g_lmZeroOne, 0.7) == 0.7f);
|
JtAssert(GLimitLm(&g_lmZeroOne, 0.7) == 0.7f);
|
||||||
assert(GLimitLm(&g_lmZeroOne, 1) == 1.f);
|
JtAssert(GLimitLm(&g_lmZeroOne, 1) == 1.f);
|
||||||
assert(GLimitLm(&g_lmZeroOne, 4) == 1.f);
|
JtAssert(GLimitLm(&g_lmZeroOne, 4) == 1.f);
|
||||||
|
|
||||||
// Clamp value using local limit
|
// Clamp value using local limit
|
||||||
LM lmFiveTen(5, 10);
|
LM lmFiveTen(5, 10);
|
||||||
assert(GLimitLm(&lmFiveTen, 1) == 5.f);
|
JtAssert(GLimitLm(&lmFiveTen, 1) == 5.f);
|
||||||
assert(GLimitLm(&lmFiveTen, 5) == 5.f);
|
JtAssert(GLimitLm(&lmFiveTen, 5) == 5.f);
|
||||||
assert(GLimitLm(&lmFiveTen, 7) == 7.f);
|
JtAssert(GLimitLm(&lmFiveTen, 7) == 7.f);
|
||||||
assert(GLimitLm(&lmFiveTen, 10) == 10.f);
|
JtAssert(GLimitLm(&lmFiveTen, 10) == 10.f);
|
||||||
assert(GLimitLm(&lmFiveTen, 99) == 10.f);
|
JtAssert(GLimitLm(&lmFiveTen, 99) == 10.f);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
#include <xform.h>
|
#include <xform.h>
|
||||||
#include "../assert.h"
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "../test.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
EXIT exit;
|
EXIT exit;
|
||||||
|
|
||||||
|
// todo: why does the custom assert macro cause errors here
|
||||||
|
|
||||||
SetExitExits(&exit, EXITS::Blocked);
|
SetExitExits(&exit, EXITS::Blocked);
|
||||||
assert(exit.fKeyed == EXITS::Blocked);
|
assert(exit.fKeyed == EXITS::Blocked);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user