2 changed files with 99 additions and 0 deletions
@ -0,0 +1,16 @@ |
|||
#ifdef UNIT_TEST
|
|||
|
|||
#include "CppUTest/CommandLineTestRunner.h"
|
|||
#include "CppUTest/TestHarness.h"
|
|||
#include "CppUTest/TestOutput.h"
|
|||
#include "CppUTest/TestTestingFixture.h"
|
|||
#include "CppUTest/PlatformSpecificFunctions.h"
|
|||
|
|||
|
|||
|
|||
int main(int ac, char** av) |
|||
{ |
|||
return CommandLineTestRunner::RunAllTests(ac, av); |
|||
} |
|||
|
|||
#endif
|
@ -0,0 +1,83 @@ |
|||
#include "CppUTest/TestHarness.h"
|
|||
#include "CppUTest/TestRegistry.h"
|
|||
#include "CppUTest/TestOutput.h"
|
|||
#include "CppUTest/TestTestingFixture.h"
|
|||
|
|||
#include "mat.h"
|
|||
|
|||
#define TESTSIZE 4
|
|||
|
|||
TEST_GROUP(Matrix) |
|||
{ |
|||
void setup() |
|||
{ |
|||
} |
|||
|
|||
void teardown() |
|||
{ |
|||
} |
|||
}; |
|||
TEST(Matrix, set) |
|||
{ |
|||
Mat<int,TESTSIZE> a ; |
|||
Mat<int,TESTSIZE> b ; |
|||
|
|||
for (int x = 0; x <TESTSIZE ; x++) |
|||
{ |
|||
for (int y = 0; y <TESTSIZE ; y++) |
|||
{ |
|||
int val = (x+1)*TESTSIZE+y; |
|||
a(x,y) = val; |
|||
CHECK_EQUAL(val,a(x,y)); |
|||
} |
|||
} |
|||
|
|||
for (int x = 0; x <TESTSIZE ; x++) |
|||
{ |
|||
for (int y = 0; y <TESTSIZE ; y++) |
|||
{ |
|||
CHECK_EQUAL(0,b(x,y)); |
|||
} |
|||
} |
|||
b = a; |
|||
for (int x = 0; x <TESTSIZE ; x++) |
|||
{ |
|||
for (int y = 0; y <TESTSIZE ; y++) |
|||
{ |
|||
int val = (x+1)*TESTSIZE+y; |
|||
CHECK_EQUAL(val,b(x,y)); |
|||
} |
|||
} |
|||
} |
|||
TEST(Matrix, init_set) |
|||
{ |
|||
Mat<int,TESTSIZE> a ; |
|||
|
|||
for (int x = 0; x <TESTSIZE ; x++) |
|||
{ |
|||
for (int y = 0; y <TESTSIZE ; y++) |
|||
{ |
|||
int val = (x+1)*TESTSIZE+y; |
|||
a(x,y) = val; |
|||
} |
|||
} |
|||
for (int x = 0; x <TESTSIZE ; x++) |
|||
{ |
|||
for (int y = 0; y <TESTSIZE ; y++) |
|||
{ |
|||
int val = (x+1)*TESTSIZE+y; |
|||
CHECK_EQUAL(val,a(x,y)); |
|||
} |
|||
} |
|||
} |
|||
TEST(Matrix, init) |
|||
{ |
|||
Mat<int,TESTSIZE> a ; |
|||
for (int x = 0; x <TESTSIZE ; x++) |
|||
{ |
|||
for (int y = 0; y <TESTSIZE ; y++) |
|||
{ |
|||
CHECK_EQUAL(0 , a(x,y) ); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue