503 lines
13 KiB
C++
503 lines
13 KiB
C++
/*
|
|
AUTOMATICALLY GENERATED FILE - DO NOT EDIT!
|
|
Please change MatrixNxN.py and re-run it
|
|
*/
|
|
/* Generated with ./VectorN.py n = 3, TYPE = int */
|
|
|
|
#include "ZUnitTest.hpp"
|
|
#include <float.h>
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <SST/SST_Vec3.h>
|
|
|
|
|
|
|
|
|
|
static const char* testSST_Math_Vec3iAdd();
|
|
static const char* testSST_Math_Vec3iAddLocal();
|
|
static const char* testSST_Math_Vec3iSubtract();
|
|
static const char* testSST_Math_Vec3iSubtractLocal();
|
|
static const char* testSST_Math_Vec3iMultiply();
|
|
static const char* testSST_Math_Vec3iMultiplyLocal();
|
|
static const char* testSST_Math_Vec3iScale();
|
|
static const char* testSST_Math_Vec3iScaleLocal();
|
|
static const char* testSST_Math_Vec3iDivide();
|
|
static const char* testSST_Math_Vec3iDivideLocal();
|
|
static const char* testSST_Math_Vec3iAbs();
|
|
static const char* testSST_Math_Vec3iAbsLocal();
|
|
static const char* testSST_Math_Vec3iNegate();
|
|
static const char* testSST_Math_Vec3iNegateLocal();
|
|
static const char* testSST_Math_Vec3iBias();
|
|
static const char* testSST_Math_Vec3iBiasLocal();
|
|
static const char* testSST_Math_Vec3iMagnitudeSquared();
|
|
static const char* testSST_Math_Vec3iDot();
|
|
// List of unit tests
|
|
ZUnitTest SST_Math_Vec3iUnitTests[] =
|
|
{
|
|
{ "testSST_Math_Vec3iAdd " , testSST_Math_Vec3iAdd },
|
|
{ "testSST_Math_Vec3iAddLocal " , testSST_Math_Vec3iAddLocal },
|
|
{ "testSST_Math_Vec3iSubtract " , testSST_Math_Vec3iSubtract },
|
|
{ "testSST_Math_Vec3iSubtractLocal " , testSST_Math_Vec3iSubtractLocal },
|
|
{ "testSST_Math_Vec3iMultiply " , testSST_Math_Vec3iMultiply },
|
|
{ "testSST_Math_Vec3iMultiplyLocal " , testSST_Math_Vec3iMultiplyLocal },
|
|
{ "testSST_Math_Vec3iScale " , testSST_Math_Vec3iScale },
|
|
{ "testSST_Math_Vec3iScaleLocal " , testSST_Math_Vec3iScaleLocal },
|
|
{ "testSST_Math_Vec3iDivide " , testSST_Math_Vec3iDivide },
|
|
{ "testSST_Math_Vec3iDivideLocal " , testSST_Math_Vec3iDivideLocal },
|
|
{ "testSST_Math_Vec3iAbs " , testSST_Math_Vec3iAbs },
|
|
{ "testSST_Math_Vec3iAbsLocal " , testSST_Math_Vec3iAbsLocal },
|
|
{ "testSST_Math_Vec3iNegate " , testSST_Math_Vec3iNegate },
|
|
{ "testSST_Math_Vec3iNegateLocal " , testSST_Math_Vec3iNegateLocal },
|
|
{ "testSST_Math_Vec3iBias " , testSST_Math_Vec3iBias },
|
|
{ "testSST_Math_Vec3iBiasLocal " , testSST_Math_Vec3iBiasLocal },
|
|
{ "testSST_Math_Vec3iMagnitudeSquared " , testSST_Math_Vec3iMagnitudeSquared },
|
|
{ "testSST_Math_Vec3iDot " , testSST_Math_Vec3iDot }
|
|
};
|
|
DECLARE_ZTESTBLOCK(SST_Math_Vec3i)
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iAdd()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i y; /* 3 vector */
|
|
SST_Vec3i w; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 11;
|
|
x.v[1] = -1;
|
|
x.v[2] = 18;
|
|
y.v[0] = -9;
|
|
y.v[1] = -16;
|
|
y.v[2] = 15;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
w.v[2] = 0;
|
|
/*
|
|
[11 -1 18]
|
|
[ -9 -16 15]
|
|
[ 2 -17 33]
|
|
*/
|
|
SST_Math_Vec3iAdd(&x,&y,&w);
|
|
TASSERT((w.v[0])==(2),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(-17),"Entry _y failed!");
|
|
TASSERT((w.v[2])==(33),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iAddLocal()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i y; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 5;
|
|
x.v[1] = -7;
|
|
x.v[2] = 5;
|
|
y.v[0] = 15;
|
|
y.v[1] = 0;
|
|
y.v[2] = 5;
|
|
/*
|
|
[ 5 -7 5]
|
|
[15 0 5]
|
|
[20 -7 10]
|
|
*/
|
|
SST_Math_Vec3iAddLocal(&x,&y); /* for accuracy */
|
|
TASSERT((x.v[0])==(20),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(-7),"Entry _y failed!");
|
|
TASSERT((x.v[2])==(10),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iSubtract()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i y; /* 3 vector */
|
|
SST_Vec3i w; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 6;
|
|
x.v[1] = 11;
|
|
x.v[2] = -12;
|
|
y.v[0] = 8;
|
|
y.v[1] = 0;
|
|
y.v[2] = 9;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
w.v[2] = 0;
|
|
/*
|
|
[ 6 11 -12]
|
|
[8 0 9]
|
|
[ -2 11 -21]
|
|
*/
|
|
SST_Math_Vec3iSubtract(&x,&y,&w);
|
|
TASSERT((w.v[0])==(-2),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(11),"Entry _y failed!");
|
|
TASSERT((w.v[2])==(-21),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iSubtractLocal()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i y; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -19;
|
|
x.v[1] = -17;
|
|
x.v[2] = 18;
|
|
y.v[0] = 9;
|
|
y.v[1] = 4;
|
|
y.v[2] = -12;
|
|
/*
|
|
[-19 -17 18]
|
|
[ 9 4 -12]
|
|
[-28 -21 30]
|
|
*/
|
|
SST_Math_Vec3iSubtractLocal(&x,&y); /* for accuracy */
|
|
TASSERT((x.v[0])==(-28),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(-21),"Entry _y failed!");
|
|
TASSERT((x.v[2])==(30),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iMultiply()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i y; /* 3 vector */
|
|
SST_Vec3i w; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 10;
|
|
x.v[1] = -15;
|
|
x.v[2] = -15;
|
|
y.v[0] = -18;
|
|
y.v[1] = -7;
|
|
y.v[2] = 17;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
w.v[2] = 0;
|
|
/*
|
|
[ 10 -15 -15]
|
|
[-18 -7 17]
|
|
[-180 105 -255]
|
|
*/
|
|
SST_Math_Vec3iMultiply(&x,&y,&w);
|
|
TASSERT((w.v[0])==(-180),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(105),"Entry _y failed!");
|
|
TASSERT((w.v[2])==(-255),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iMultiplyLocal()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i y; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -14;
|
|
x.v[1] = 15;
|
|
x.v[2] = -2;
|
|
y.v[0] = 19;
|
|
y.v[1] = -4;
|
|
y.v[2] = -4;
|
|
/*
|
|
[-14 15 -2]
|
|
[19 -4 -4]
|
|
[-266 -60 8]
|
|
*/
|
|
SST_Math_Vec3iMultiplyLocal(&x,&y); /* for accuracy */
|
|
TASSERT((x.v[0])==(-266),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(-60),"Entry _y failed!");
|
|
TASSERT((x.v[2])==(8),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iDivide()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i y; /* 3 vector */
|
|
SST_Vec3i w; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 28;
|
|
x.v[1] = 23;
|
|
x.v[2] = 8;
|
|
y.v[0] = 2;
|
|
y.v[1] = 2;
|
|
y.v[2] = 29;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
w.v[2] = 0;
|
|
/*
|
|
[28 23 8]
|
|
[ 2 2 29]
|
|
[14 11 0]
|
|
*/
|
|
SST_Math_Vec3iDivide(&x,&y,&w);
|
|
TASSERT((w.v[0])==(14),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(11),"Entry _y failed!");
|
|
TASSERT((w.v[2])==(0),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iDivideLocal()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i y; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 31;
|
|
x.v[1] = 36;
|
|
x.v[2] = 33;
|
|
y.v[0] = 1;
|
|
y.v[1] = 9;
|
|
y.v[2] = 16;
|
|
/*
|
|
[31 36 33]
|
|
[ 1 9 16]
|
|
[31 4 2]
|
|
*/
|
|
SST_Math_Vec3iDivideLocal(&x,&y); /* for accuracy */
|
|
TASSERT((x.v[0])==(31),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(4),"Entry _y failed!");
|
|
TASSERT((x.v[2])==(2),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iScale()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i w; /* 3 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -11;
|
|
x.v[1] = -6;
|
|
x.v[2] = 12;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
w.v[2] = 0;
|
|
a = 2;
|
|
/*
|
|
[-11 -6 12]
|
|
[-22 -12 24]
|
|
*/
|
|
SST_Math_Vec3iScale(&x,a,&w);
|
|
TASSERT((w.v[0])==(-22),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(-12),"Entry _y failed!");
|
|
TASSERT((w.v[2])==(24),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iScaleLocal()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 1;
|
|
x.v[1] = 19;
|
|
x.v[2] = -8;
|
|
a = 2;
|
|
/*
|
|
[ 1 19 -8]
|
|
[ 2 38 -16]
|
|
*/
|
|
SST_Math_Vec3iScaleLocal(&x,a); /* for accuracy */
|
|
TASSERT((x.v[0])==(2),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(38),"Entry _y failed!");
|
|
TASSERT((x.v[2])==(-16),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iAbs()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i w; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 16;
|
|
x.v[1] = 15;
|
|
x.v[2] = -14;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
w.v[2] = 0;
|
|
/*
|
|
[ 16 15 -14]
|
|
[16 15 14]
|
|
*/
|
|
SST_Math_Vec3iAbs(&x,&w);
|
|
TASSERT((w.v[0])==(16),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(15),"Entry _y failed!");
|
|
TASSERT((w.v[2])==(14),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iAbsLocal()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -1;
|
|
x.v[1] = -12;
|
|
x.v[2] = -18;
|
|
/*
|
|
[ -1 -12 -18]
|
|
[ 1 12 18]
|
|
*/
|
|
SST_Math_Vec3iAbsLocal(&x); /* for accuracy */
|
|
TASSERT((x.v[0])==(1),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(12),"Entry _y failed!");
|
|
TASSERT((x.v[2])==(18),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iBias()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i w; /* 3 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -12;
|
|
x.v[1] = -9;
|
|
x.v[2] = -2;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
w.v[2] = 0;
|
|
a = -20;
|
|
/*
|
|
[-12 -9 -2]
|
|
[-24 -18 -4]
|
|
*/
|
|
SST_Math_Vec3iBias(&x,a,&w);
|
|
TASSERT((w.v[0])==(-32),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(-29),"Entry _y failed!");
|
|
TASSERT((w.v[2])==(-22),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iBiasLocal()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 0;
|
|
x.v[1] = 19;
|
|
x.v[2] = -15;
|
|
a = 16;
|
|
/*
|
|
[ 0 19 -15]
|
|
[ 0 38 -30]
|
|
*/
|
|
SST_Math_Vec3iBiasLocal(&x,a); /* for accuracy */
|
|
TASSERT((x.v[0])==(16),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(35),"Entry _y failed!");
|
|
TASSERT((x.v[2])==(1),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iNegate()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i w; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 14;
|
|
x.v[1] = -14;
|
|
x.v[2] = -9;
|
|
w.v[0] = 0;
|
|
w.v[1] = 0;
|
|
w.v[2] = 0;
|
|
/*
|
|
[ 14 -14 -9]
|
|
[-14 14 9]
|
|
*/
|
|
SST_Math_Vec3iNegate(&x,&w);
|
|
TASSERT((w.v[0])==(-14),"Entry _x failed!");
|
|
TASSERT((w.v[1])==(14),"Entry _y failed!");
|
|
TASSERT((w.v[2])==(9),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iNegateLocal()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
/* Resetting test vectors */
|
|
x.v[0] = 15;
|
|
x.v[1] = 16;
|
|
x.v[2] = 1;
|
|
/*
|
|
[15 16 1]
|
|
[-15 -16 -1]
|
|
*/
|
|
SST_Math_Vec3iNegateLocal(&x); /* for accuracy */
|
|
TASSERT((x.v[0])==(-15),"Entry _x failed!");
|
|
TASSERT((x.v[1])==(-16),"Entry _y failed!");
|
|
TASSERT((x.v[2])==(-1),"Entry _z failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iMagnitudeSquared()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -15;
|
|
x.v[1] = 13;
|
|
x.v[2] = 14;
|
|
/*
|
|
[-15 13 14]
|
|
590
|
|
*/
|
|
a = SST_Math_Vec3iMagnitudeSquared(&x);
|
|
TASSERT((a)==(590),"MagnitudeSquared failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|
|
static const char* testSST_Math_Vec3iDot()
|
|
{
|
|
SST_Vec3i x; /* 3 vector */
|
|
SST_Vec3i y; /* 3 vector */
|
|
int a; /* scalar */
|
|
/* Resetting test vectors */
|
|
x.v[0] = -20;
|
|
x.v[1] = -1;
|
|
x.v[2] = -4;
|
|
y.v[0] = 12;
|
|
y.v[1] = -20;
|
|
y.v[2] = -12;
|
|
/*
|
|
[-20 -1 -4]
|
|
-172
|
|
*/
|
|
a = SST_Math_Vec3iDot(&x,&y);
|
|
TASSERT((a)==(-172),"Dot failed!");
|
|
return ZTEST_SUCCESS;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
|