Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sparsematrix.tests.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Robot Group Leipzig *
3  * martius@informatik.uni-leipzig.de *
4  * fhesse@informatik.uni-leipzig.de *
5  * der@informatik.uni-leipzig.de *
6  * guettler@informatik.uni-leipzig.de *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  ***************************************************************************
23  * *
24  * DESCRIPTION *
25  *
26  * UNIT TESTS for sparse matrices *
27  * *
28  * *
29  * $Log$
30  * Revision 1.2 2011-11-11 15:43:06 martius
31  * color schemas (palettes and aliases) supported
32  * small compile error removed
33  * DUNITTEST removed in selforg-config and oderobots-config
34  *
35  * Revision 1.1 2009/08/03 08:35:20 guettler
36  * first tests, to be tested
37  * *
38  * *
39  **************************************************************************/
40 #ifdef UNITTEST
41 #include "unit_test.hpp"
42 #include <string.h>
43 #include <cmath>
44 #include <algorithm>
45 using namespace matrix;
46 
47 
48 UNIT_TEST_DEFINES
49 
50 DEFINE_TEST( check_creation ) {
51  std::cout << "\n -[ Creation and Access ]-\n";
53  double testdata[9]={1,0,0, 0,1,0, 0,0,1};
54  M1.set(testdata);
55  unit_assert( "identity_set=id",
56  M1[0] == 1 && M1[1] == 0 && M1[2] == 0 &&
57  M1[3] == 0 && M1[4] == 1 && M1[5] == 0 &&
58  M1[6] == 0 && M1[8] == 0 && M1[9] == 1);
59  double testdata2[12]={1,2,3, 4,5,6, 7,8,9, 10,11,12};
61  M3.set(testdata2);
62  unit_assert( "dimension of matrix", M3.getM() == 4 && M3.getN() == 3 );
63  unit_assert( "field check",
64  M3.val(0,2) == 3 && M3.val(2,1) == 8 && M3.val(3,0) == 10 );
65  unit_pass();
66 }
67 
68 
69 UNIT_TEST_RUN( "SparseMatrix Tests" )
70  ADD_TEST( check_creation )
71 
72  UNIT_TEST_END
73 
74 #endif // UNITTEST
UNIT_TEST_DEFINES DEFINE_TEST(CheckSetGet)
Definition: configurabletest.cpp:51
sparse matrix which uses an HashTable first (fast implemented) version
Definition: sparsematrix.h:37