Melee Modding Library  2.0.0
A C library for modding Super Smash Bros Melee
unit_test.h
Go to the documentation of this file.
1 
7 #ifndef MML_UNIT_TEST_H
8 #define MML_UNIT_TEST_H
9 
10 #include "print.h"
11 #include "math.h"
12 #include "gctypes.h"
13 
16 #define STRINGIFY(x) #x
17 #define TOSTRING(x) STRINGIFY(x)
18 #define ASSERT_MSG "assert failed: " __FILE__ ":" TOSTRING(__LINE__)
19 
20 #define APPROX_ZERO(x, tol) (fabs(x) < tol)
21 
24 #define REQUIRE(condition) \
25 do { \
26  if (!(condition)) \
27  { \
28  print(ASSERT_MSG); \
29  _tests_passed = false; \
30  } \
31 } while (0)
32 
37 #define REQUIRE_FLT_EQ(L, R, tol) REQUIRE(APPROX_ZERO((L) - (R), tol))
38 
40 #define UNIT_TEST static bool _tests_passed = true
41 
46 #define END_TEST \
47 do { \
48  if (_tests_passed) \
49  { \
50  print("all tests passed!"); \
51  } \
52 } while (0)
53 
54 #endif
55 
Useful math functions.
Data types for the gamecube.