2013-11-10 20:14:10 +00:00
|
|
|
#include "BaseTestCase.h"
|
2013-11-10 16:03:07 +00:00
|
|
|
|
2013-11-16 18:12:42 +00:00
|
|
|
#include "Zone.h"
|
|
|
|
#include "Vector3.h"
|
2013-11-10 16:03:07 +00:00
|
|
|
|
2013-11-10 20:14:10 +00:00
|
|
|
class Zone_Test : public BaseTestCase {
|
|
|
|
protected:
|
|
|
|
virtual void SetUp() {
|
2013-11-16 18:12:42 +00:00
|
|
|
zone = new Zone;
|
2013-11-10 20:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void TearDown()
|
|
|
|
{
|
2013-11-16 18:12:42 +00:00
|
|
|
delete zone;
|
2013-11-10 20:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Zone* zone;
|
|
|
|
};
|
2013-11-10 16:03:07 +00:00
|
|
|
|
2013-11-10 20:14:10 +00:00
|
|
|
TEST_F(Zone_Test, absolute_height)
|
|
|
|
{
|
2013-11-16 18:12:42 +00:00
|
|
|
zone->addHeightRangeQuick(1.0, -1.0, 2.0, 5.0, 6.0);
|
|
|
|
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -10.0, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -2.0, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -1.0, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -0.5, 0.0), VECTOR_UP), 1.0 / 6.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.0, 0.0), VECTOR_UP), 1.0 / 3.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.5, 0.0), VECTOR_UP), 0.5);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 2.0, 0.0), VECTOR_UP), 1.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 2.1, 0.0), VECTOR_UP), 1.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 3.5, 0.0), VECTOR_UP), 1.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 4.9, 0.0), VECTOR_UP), 1.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 5.0, 0.0), VECTOR_UP), 1.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 5.2, 0.0), VECTOR_UP), 0.8);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 5.7, 0.0), VECTOR_UP), 0.3);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 6.0, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 15.0, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 150.0, 0.0), VECTOR_UP), 0.0);
|
2013-11-10 16:03:07 +00:00
|
|
|
}
|
|
|
|
|
2013-11-10 20:14:10 +00:00
|
|
|
TEST_F(Zone_Test, relative_height)
|
2013-11-10 16:03:07 +00:00
|
|
|
{
|
2013-11-16 18:12:42 +00:00
|
|
|
zone->addHeightRangeQuick(1.0, 0.2, 0.3, 0.6, 0.9);
|
|
|
|
zone->setRelativeHeight(-2.0, 2.0, 8.0);
|
|
|
|
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -10.0, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -2.1, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -2.0, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -1.0, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -0.5, 0.0), VECTOR_UP), 0.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, -0.2, 0.0), VECTOR_UP), 0.25);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.0, 0.0), VECTOR_UP), 0.5);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.3, 0.0), VECTOR_UP), 0.875);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 0.5, 0.0), VECTOR_UP), 1.0);
|
|
|
|
EXPECT_DOUBLE_EQ(zone->getValue(Vector3(0.0, 1.0, 0.0), VECTOR_UP), 1.0);
|
2013-11-10 16:03:07 +00:00
|
|
|
}
|