1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include "../Tests.h"
- #include "core/View.h"
- static void testFromAngles() {
- View v;
- initView(&v);
- updateDirections(&v, 0.0f, 0.0f);
- TEST_V3(&V(0.0f, 1.0f, 0.0f), &v.up);
- TEST_V3(&V(0.0f, -1.0f, 0.0f), &v.down);
- TEST_V3(&V(0.0f, 0.0f, -1.0f), &v.left);
- TEST_V3(&V(0.0f, 0.0f, 1.0f), &v.right);
- TEST_V3(&V(1.0f, 0.0f, 0.0f), &v.front);
- TEST_V3(&V(-1.0f, 0.0f, 0.0f), &v.back);
- }
- static void testFromQuaternion() {
- View v;
- initView(&v);
- updateDirectionsQ(&v, &UNIT_QUATERNION);
- TEST_V3(&V(0.0f, 1.0f, 0.0f), &v.up);
- TEST_V3(&V(0.0f, -1.0f, 0.0f), &v.down);
- TEST_V3(&V(0.0f, 0.0f, -1.0f), &v.left);
- TEST_V3(&V(0.0f, 0.0f, 1.0f), &v.right);
- TEST_V3(&V(1.0f, 0.0f, 0.0f), &v.front);
- TEST_V3(&V(-1.0f, 0.0f, 0.0f), &v.back);
- }
- static void testUpdateMatrix() {
- View v;
- initView(&v);
- Matrix* m = updateMatrix(&v, &V(1.0f, 2.0f, 3.0f));
- char buffer[128];
- toStringMatrix(m, buffer, sizeof(buffer));
- TEST_STRING("[[0.000, 0.000, 0.000, -0.000], "
- "[0.000, 0.000, 0.000, -0.000], "
- "[0.000, 0.000, 0.000, -0.000], "
- "[0.000, 0.000, 0.000, 1.000]]",
- buffer);
- }
- void testView() {
- testFromAngles();
- testFromQuaternion();
- testUpdateMatrix();
- }
|