1
0
forked from 0ad/0ad
0ad/source/maths/tests/test_Bound.h
Ykkrosh 147d4f2bd3 # Fixed minor shadow bug
CBound operator+= updated the minimum value or the maximum value, but
never both. (I think the operator+=(CVector3D) has always been buggy
(because it assumes min<max, which isn't true of empty bounds), and I
propagated the error to operator+=(CBound) ages ago.)
Added test cases, and fixed.

This was SVN commit r4244.
2006-08-25 12:52:26 +00:00

41 lines
652 B
C++

#include "lib/self_test.h"
#include "maths/Bound.h"
class TestBound : public CxxTest::TestSuite
{
public:
void test_empty()
{
CBound bound;
TS_ASSERT(bound.IsEmpty());
bound += CVector3D(1, 2, 3);
TS_ASSERT(! bound.IsEmpty());
bound.SetEmpty();
TS_ASSERT(bound.IsEmpty());
}
void test_extend_vector()
{
CBound bound;
CVector3D v (1, 2, 3);
bound += v;
CVector3D centre;
bound.GetCentre(centre);
TS_ASSERT_EQUALS(centre, v);
}
void test_extend_bound()
{
CBound bound;
CVector3D v (1, 2, 3);
CBound b (v, v);
bound += b;
CVector3D centre;
bound.GetCentre(centre);
TS_ASSERT_EQUALS(centre, v);
}
};