No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

matrix.cpp 1.3 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cppunit/extensions/HelperMacros.h>
  14. #include <cppunit/TestCaller.h>
  15. #include <cppunit/TestCase.h>
  16. #include <cppunit/TestSuite.h>
  17. #include "core.h"
  18. class MatrixTest : public CppUnit::TestCase
  19. {
  20. CPPUNIT_TEST_SUITE(MatrixTest);
  21. CPPUNIT_TEST(test_mat_mul);
  22. CPPUNIT_TEST_SUITE_END();
  23. public:
  24. MatrixTest() : CppUnit::TestCase("Matrix Test") {}
  25. void setUp() {}
  26. void tearDown() {}
  27. void test_mat_mul()
  28. {
  29. float4 v0(1.0f, 0.0f, 0.0f, 0.0f);
  30. float4 v1(0.0f, 1.0f, 0.0f, 0.0f);
  31. float4 v2(0.0f, 0.0f, 1.0f, 0.0f);
  32. float4 v3(0.0f, 0.0f, 0.0f, 1.0f);
  33. float4x4 m0(v0, v1, v2, v3);
  34. float4x4 m1(v0, v1, v2, v3);
  35. float4x4 m2 = m0 * m1;
  36. CPPUNIT_ASSERT(m2[0][0] == 1.0f);
  37. CPPUNIT_ASSERT(m2[1][1] == 1.0f);
  38. CPPUNIT_ASSERT(m2[2][2] == 1.0f);
  39. CPPUNIT_ASSERT(m2[3][3] == 1.0f);
  40. }
  41. };
  42. CPPUNIT_TEST_SUITE_REGISTRATION(MatrixTest);