Last active
August 23, 2016 23:28
-
-
Save bvisness/bd701551a4e206eab4a61477805a9a7a to your computer and use it in GitHub Desktop.
"Test" for Handmade Math
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This file actually includes the implementations from HandmadeMath.h so the | |
* main test can link with them. | |
*/ | |
#define HANDMADE_MATH_NO_INLINE | |
#define HANDMADE_MATH_IMPLEMENTATION | |
#define HANDMADE_MATH_CPP_MODE | |
#include "HandmadeMath.h" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This file includes HandmadeMath.h, but not the implementations. This is to | |
* ensure that all the headers are present. | |
*/ | |
#define HANDMADE_MATH_CPP_MODE | |
#include "HandmadeMath.h" | |
int main() { | |
hmm_vec2 v2 = HMM_Vec2(1, 2); | |
hmm_vec3 v3 = HMM_Vec3(1, 2, 3); | |
hmm_vec4 v4 = HMM_Vec4(1, 2, 3, 4); | |
hmm_mat4 m4 = { | |
1, 1, 1, 1, | |
1, 1, 1, 1, | |
1, 1, 1, 1, | |
1, 1, 1, 1 | |
}; | |
HMM_Add(v2, v2); | |
HMM_Add(v3, v3); | |
HMM_Add(v4, v4); | |
v2 + v2; | |
v3 + v3; | |
v4 + v4; | |
v2 += v2; | |
v3 += v3; | |
v4 += v4; | |
HMM_Subtract(v2, v2); | |
HMM_Subtract(v3, v3); | |
HMM_Subtract(v4, v4); | |
v2 - v2; | |
v3 - v3; | |
v4 - v4; | |
v2 -= v2; | |
v3 -= v3; | |
v4 -= v4; | |
HMM_Multiply(v2, 1); | |
HMM_Multiply(v3, 1); | |
HMM_Multiply(v4, 1); | |
v2 * 1; | |
1 * v2; | |
v3 * 1; | |
1 * v3; | |
v4 * 1; | |
1 * v4; | |
HMM_Multiply(v2, v2); | |
HMM_Multiply(v3, v3); | |
HMM_Multiply(v4, v4); | |
v2 * v2; | |
v3 * v3; | |
v4 * v4; | |
v2 *= 1; | |
v3 *= 1; | |
v4 *= 1; | |
v2 *= v2; | |
v3 *= v3; | |
v4 *= v4; | |
HMM_Divide(v2, 1); | |
HMM_Divide(v3, 1); | |
HMM_Divide(v4, 1); | |
v2 / 1; | |
v3 / 1; | |
v4 / 1; | |
HMM_Divide(v2, v2); | |
HMM_Divide(v3, v3); | |
HMM_Divide(v4, v4); | |
v2 / v2; | |
v3 / v3; | |
v4 / v4; | |
v2 /= 1; | |
v3 /= 1; | |
v4 /= 1; | |
v2 /= v2; | |
v3 /= v3; | |
v4 /= v4; | |
HMM_Add(m4, m4); | |
HMM_Subtract(m4, m4); | |
HMM_Multiply(m4, m4); | |
m4 + m4; | |
m4 - m4; | |
m4 * m4; | |
m4 += m4; | |
m4 -= m4; | |
HMM_Multiply(m4, 1); | |
HMM_Divide(m4, 1); | |
m4 * 1; | |
1 * m4; | |
m4 / 1; | |
m4 *= 1; | |
m4 /= 1; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is far from actual unit tests, but it at least ensures that all the expected vector and matrix operations compile. (CPP-wise, anyway!)