You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

83 lines
1.5 KiB

#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) );
}
}
}