Browse Source

add first test code

master
philipp schoenberger 10 years ago
parent
commit
4b4947636b
  1. 16
      lwrserv/test/main.cpp
  2. 83
      lwrserv/test/test_mat.cpp

16
lwrserv/test/main.cpp

@ -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

83
lwrserv/test/test_mat.cpp

@ -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) );
}
}
}
Loading…
Cancel
Save