452 lines
12 KiB
C++
452 lines
12 KiB
C++
/*
|
|
AUTOMATICALLY GENERATED FILE - DO NOT EDIT!
|
|
Please change MatrixNxN.py and re-run it
|
|
*/
|
|
/* Generated with ./VectorN.py n = 2, TYPE = int */
|
|
|
|
#include "ZUnitTest.hpp"
|
|
#include <float.h>
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <SST/SST_Vec2.h>
|
|
|
|
|
|
|
|
|
|
static const char* testSST_Math_Vec2iAdd();
|
|
static const char* testSST_Math_Vec2iAddLocal();
|
|
static const char* testSST_Math_Vec2iSubtract();
|
|
static const char* testSST_Math_Vec2iSubtractLocal();
|
|
static const char* testSST_Math_Vec2iMultiply();
|
|
static const char* testSST_Math_Vec2iMultiplyLocal();
|
|
static const char* testSST_Math_Vec2iScale();
|
|
static const char* testSST_Math_Vec2iScaleLocal();
|
|
static const char* testSST_Math_Vec2iDivide();
|
|
static const char* testSST_Math_Vec2iDivideLocal();
|
|
static const char* testSST_Math_Vec2iAbs();
|
|
static const char* testSST_Math_Vec2iAbsLocal();
|
|
static const char* testSST_Math_Vec2iNegate();
|
|
static const char* testSST_Math_Vec2iNegateLocal();
|
|
static const char* testSST_Math_Vec2iBias();
|
|
static const char* testSST_Math_Vec2iBiasLocal();
|
|
static const char* testSST_Math_Vec2iMagnitudeSquared();
|
|
static const char* testSST_Math_Vec2iDot();
|
|
// List of unit tests
|
|
ZUnitTest SST_Math_Vec2iUnitTests[] =
|
|
{
|
|
{ "testSST_Math_Vec2iAdd " , testSST_Math_Vec2iAdd },
|
|
{ "testSST_Math_Vec2iAddLocal " , testSST_Math_Vec2iAddLocal },
|
|
{ "testSST_Math_Vec2iSubtract " , testSST_Math_Vec2iSubtract },
|
|
{ "testSST_Math_Vec2iSubtractLocal " , testSST_Math_Vec2iSubtractLocal },
|
|
{ "testSST_Math_Vec2iMultiply " , testSST_Math_Vec2iMultiply },
|
|
{ "testSST_Math_Vec2iMultiplyLocal " , testSST_Math_Vec2iMultiplyLocal },
|
|
{ "testSST_Math_Vec2iScale " , testSST_Math_Vec2iScale },
|
|
{ "testSST_Math_Vec2iScaleLocal " , testSST_Math_Vec2iScaleLocal },
|
|
{ "testSST_Math_Vec2iDivide " , testSST_Math_Vec2iDivide },
|
|
{ "testSST_Math_Vec2iDivideLocal " , testSST_Math_Vec2iDivideLocal },
|
|
{ "testSST_Math_Vec2iAbs " , testSST_Math_Vec2iAbs },
|
|
{ "testSST_Math_Vec2iAbsLocal " , testSST_Math_Vec2iAbsLocal },
|
|
{ "testSST_Math_Vec2iNegate " , testSST_Math_Vec2iNegate },
|
|
{ "testSST_Math_Vec2iNegateLocal " , testSST_Math_Vec2iNegateLocal },
|
|
{ "testSST_Math_Vec2iBias " , testSST_Math_Vec2iBias },
|
|
{ "testSST_Math_Vec2iBiasLocal " , testSST_Math_Vec2iBiasLocal },
|
|
{ "testSST_Math_Vec2iMagnitudeSquared " , testSST_Math_Vec2iMagnitudeSquared },
|
|
{ "testSST_Math_Vec2iDot " , testSST_Math_Vec2iDot }
|
|
};
|
|
DECLARE_ZTESTBLOCK(SST_Math_Vec2i)
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iAdd()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i y; /* 2 vector */
|
|
SST_Vec2i w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 14;
|
|
x.v[1] = -13;
|
|
y.v[0] = 6;
|
|
y.v[1] = -12;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
/*
|
|
[ 14 -13]
|
|
[ 6 -12]
|
|
[ 20 -25]
|
|
*/
|
|
SST_Math_Vec2iAdd(&x,&y,&w);
|
|
TASSERT((w.v[0])==(20),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(-25),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iAddLocal()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -10;
|
|
x.v[1] = -20;
|
|
y.v[0] = -6;
|
|
y.v[1] = 17;
|
|
/*
|
|
[-10 -20]
|
|
[-6 17]
|
|
[-16 -3]
|
|
*/
|
|
SST_Math_Vec2iAddLocal(&x,&y); /* for accuracy */
|
|
TASSERT((x.v[0])==(-16),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(-3),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iSubtract()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i y; /* 2 vector */
|
|
SST_Vec2i w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -3;
|
|
x.v[1] = -9;
|
|
y.v[0] = 9;
|
|
y.v[1] = -20;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
/*
|
|
[-3 -9]
|
|
[ 9 -20]
|
|
[-12 11]
|
|
*/
|
|
SST_Math_Vec2iSubtract(&x,&y,&w);
|
|
TASSERT((w.v[0])==(-12),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(11),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iSubtractLocal()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -8;
|
|
x.v[1] = 0;
|
|
y.v[0] = 14;
|
|
y.v[1] = 4;
|
|
/*
|
|
[-8 0]
|
|
[14 4]
|
|
[-22 -4]
|
|
*/
|
|
SST_Math_Vec2iSubtractLocal(&x,&y); /* for accuracy */
|
|
TASSERT((x.v[0])==(-22),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(-4),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iMultiply()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i y; /* 2 vector */
|
|
SST_Vec2i w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 15;
|
|
x.v[1] = 14;
|
|
y.v[0] = 16;
|
|
y.v[1] = 7;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
/*
|
|
[15 14]
|
|
[16 7]
|
|
[240 98]
|
|
*/
|
|
SST_Math_Vec2iMultiply(&x,&y,&w);
|
|
TASSERT((w.v[0])==(240),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(98),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iMultiplyLocal()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 2;
|
|
x.v[1] = -8;
|
|
y.v[0] = 13;
|
|
y.v[1] = -14;
|
|
/*
|
|
[ 2 -8]
|
|
[ 13 -14]
|
|
[ 26 112]
|
|
*/
|
|
SST_Math_Vec2iMultiplyLocal(&x,&y); /* for accuracy */
|
|
TASSERT((x.v[0])==(26),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(112),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iDivide()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i y; /* 2 vector */
|
|
SST_Vec2i w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 37;
|
|
x.v[1] = 28;
|
|
y.v[0] = 16;
|
|
y.v[1] = 7;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
/*
|
|
[37 28]
|
|
[16 7]
|
|
[2 4]
|
|
*/
|
|
SST_Math_Vec2iDivide(&x,&y,&w);
|
|
TASSERT((w.v[0])==(2),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(4),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iDivideLocal()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i y; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 15;
|
|
x.v[1] = 25;
|
|
y.v[0] = 19;
|
|
y.v[1] = 1;
|
|
/*
|
|
[15 25]
|
|
[19 1]
|
|
[ 0 25]
|
|
*/
|
|
SST_Math_Vec2iDivideLocal(&x,&y); /* for accuracy */
|
|
TASSERT((x.v[0])==(0),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(25),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iScale()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i w; /* 2 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -14;
|
|
x.v[1] = 0;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
a = 2;
|
|
/*
|
|
[-14 0]
|
|
[-28 0]
|
|
*/
|
|
SST_Math_Vec2iScale(&x,a,&w);
|
|
TASSERT((w.v[0])==(-28),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(0),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iScaleLocal()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -20;
|
|
x.v[1] = -1;
|
|
a = 2;
|
|
/*
|
|
[-20 -1]
|
|
[-40 -2]
|
|
*/
|
|
SST_Math_Vec2iScaleLocal(&x,a); /* for accuracy */
|
|
TASSERT((x.v[0])==(-40),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(-2),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iAbs()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -13;
|
|
x.v[1] = 6;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
/*
|
|
[-13 6]
|
|
[13 6]
|
|
*/
|
|
SST_Math_Vec2iAbs(&x,&w);
|
|
TASSERT((w.v[0])==(13),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(6),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iAbsLocal()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 12;
|
|
x.v[1] = 16;
|
|
/*
|
|
[12 16]
|
|
[12 16]
|
|
*/
|
|
SST_Math_Vec2iAbsLocal(&x); /* for accuracy */
|
|
TASSERT((x.v[0])==(12),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(16),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iBias()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i w; /* 2 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -10;
|
|
x.v[1] = 5;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
a = -8;
|
|
/*
|
|
[-10 5]
|
|
[-20 10]
|
|
*/
|
|
SST_Math_Vec2iBias(&x,a,&w);
|
|
TASSERT((w.v[0])==(-18),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(-3),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iBiasLocal()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 7;
|
|
x.v[1] = -9;
|
|
a = -6;
|
|
/*
|
|
[ 7 -9]
|
|
[ 14 -18]
|
|
*/
|
|
SST_Math_Vec2iBiasLocal(&x,a); /* for accuracy */
|
|
TASSERT((x.v[0])==(1),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(-15),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iNegate()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i w; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -4;
|
|
x.v[1] = 9;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
/*
|
|
[-4 9]
|
|
[ 4 -9]
|
|
*/
|
|
SST_Math_Vec2iNegate(&x,&w);
|
|
TASSERT((w.v[0])==(4),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(-9),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iNegateLocal()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -8;
|
|
x.v[1] = 2;
|
|
/*
|
|
[-8 2]
|
|
[ 8 -2]
|
|
*/
|
|
SST_Math_Vec2iNegateLocal(&x); /* for accuracy */
|
|
TASSERT((x.v[0])==(8),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(-2),"Entry _y failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iMagnitudeSquared()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -20;
|
|
x.v[1] = -4;
|
|
/*
|
|
[-20 -4]
|
|
416
|
|
*/
|
|
a = SST_Math_Vec2iMagnitudeSquared(&x);
|
|
TASSERT((a)==(416),"MagnitudeSquared failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec2iDot()
|
|
{
|
|
SST_Vec2i x; /* 2 vector */
|
|
SST_Vec2i y; /* 2 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 16;
|
|
x.v[1] = 11;
|
|
y.v[0] = 0;
|
|
y.v[1] = 8;
|
|
/*
|
|
[16 11]
|
|
88
|
|
*/
|
|
a = SST_Math_Vec2iDot(&x,&y);
|
|
TASSERT((a)==(88),"Dot failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|