source: trunk/test/matrix.cpp @ 642

Last change on this file since 642 was 642, checked in by sam, 10 years ago

Add an optional cppunit dependency for unit tests.

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
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
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cppunit/extensions/HelperMacros.h>
16#include <cppunit/TestCaller.h>
17#include <cppunit/TestCase.h>
18#include <cppunit/TestSuite.h>
19
20#include "core.h"
21
22class MatrixTest : public CppUnit::TestCase
23{
24    CPPUNIT_TEST_SUITE(MatrixTest);
25    CPPUNIT_TEST(test_mat_mul);
26    CPPUNIT_TEST_SUITE_END();
27
28public:
29    MatrixTest() : CppUnit::TestCase("Matrix Test") {}
30
31    void setUp() {}
32
33    void tearDown() {}
34
35    void test_mat_mul()
36    {
37        float4 v0(1.0f, 0.0f, 0.0f, 0.0f);
38        float4 v1(0.0f, 1.0f, 0.0f, 0.0f);
39        float4 v2(0.0f, 0.0f, 1.0f, 0.0f);
40        float4 v3(0.0f, 0.0f, 0.0f, 1.0f);
41        float4x4 m0(v0, v1, v2, v3);
42        float4x4 m1(v0, v1, v2, v3);
43        float4x4 m2 = m0 * m1;
44
45        CPPUNIT_ASSERT(m2[0][0] == 1.0f);
46        CPPUNIT_ASSERT(m2[1][1] == 1.0f);
47        CPPUNIT_ASSERT(m2[2][2] == 1.0f);
48        CPPUNIT_ASSERT(m2[3][3] == 1.0f);
49    }
50};
51
52CPPUNIT_TEST_SUITE_REGISTRATION(MatrixTest);
53
Note: See TracBrowser for help on using the repository browser.