forked from 0ad/0ad
Ykkrosh
147d4f2bd3
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.
41 lines
652 B
C++
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);
|
|
}
|
|
};
|