| 1 |
/*! |
| 2 |
\file |
| 3 |
\brief CalculateGeometry ‚̃eƒXƒg |
| 4 |
|
| 5 |
\author Satofumi KAMIMURA |
| 6 |
|
| 7 |
$Id$ |
| 8 |
*/ |
| 9 |
|
| 10 |
#include "TestCalculateGeometry.h" |
| 11 |
#include "CalculateGeometry.h" |
| 12 |
|
| 13 |
|
| 14 |
CPPUNIT_TEST_SUITE_REGISTRATION(CalculateGeometryTest); |
| 15 |
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(CalculateGeometryTest, |
| 16 |
"CalculateGeometryTest"); |
| 17 |
|
| 18 |
using namespace beego; |
| 19 |
|
| 20 |
|
| 21 |
void CalculateGeometryTest::compileTest(void) { |
| 22 |
|
| 23 |
Position<int> pos(0, 0, deg(0)); |
| 24 |
Position<int> line(1000, 0, deg(0)); |
| 25 |
calculate_getLength_toPosition<int>(pos, line); |
| 26 |
|
| 27 |
Grid<int> point(0, 0); |
| 28 |
calculate_getLength_toPoint(pos, point); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
void CalculateGeometryTest::toPositionTest(void) { |
| 33 |
|
| 34 |
Position<int> pos(0, 0, deg(0)); |
| 35 |
Position<int> line(+1000, 0, deg(0)); |
| 36 |
|
| 37 |
int length = calculate_getLength_toPosition<int>(pos, line); |
| 38 |
CPPUNIT_ASSERT_EQUAL(-1000, length); |
| 39 |
|
| 40 |
set_Position(&line, -1000, 0, deg(0)); |
| 41 |
length = calculate_getLength_toPosition<int>(pos, line); |
| 42 |
CPPUNIT_ASSERT_EQUAL(+1000, length); |
| 43 |
|
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
void CalculateGeometryTest::toPointTest(void) { |
| 48 |
|
| 49 |
Position<int> pos(0, 0, deg(0)); |
| 50 |
Grid<int> point(1000, 0); |
| 51 |
|
| 52 |
int length = calculate_getLength_toPoint<int>(pos, point); |
| 53 |
CPPUNIT_ASSERT_EQUAL(1000, length); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
void CalculateGeometryTest::toLineTest(void) { |
| 58 |
|
| 59 |
Position<int> pos(0, 0, deg(0)); |
| 60 |
Grid<int> p0(0, 3000); |
| 61 |
Grid<int> p1(+4000, 3000); |
| 62 |
int length = calculate_getLength_toLine<int>(pos, p0, p1); |
| 63 |
CPPUNIT_ASSERT_EQUAL(3000, length); |
| 64 |
|
| 65 |
set_Position(&pos, +4000, 0, deg(0)); |
| 66 |
length = calculate_getLength_toLine<int>(pos, p0, p1); |
| 67 |
CPPUNIT_ASSERT_DOUBLES_EQUAL(3000, length, 1); |
| 68 |
|
| 69 |
set_Position(&pos, +8000, 0, deg(0)); |
| 70 |
length = calculate_getLength_toLine<int>(pos, p0, p1); |
| 71 |
CPPUNIT_ASSERT_DOUBLES_EQUAL(5000, length, 1); |
| 72 |
|
| 73 |
set_Position(&pos, -4000, 3000, deg(0)); |
| 74 |
length = calculate_getLength_toLine<int>(pos, p0, p1); |
| 75 |
CPPUNIT_ASSERT_EQUAL(4000, length); |
| 76 |
|
| 77 |
set_Position(&pos, +6000, 3000, deg(0)); |
| 78 |
length = calculate_getLength_toLine<int>(pos, p0, p1); |
| 79 |
CPPUNIT_ASSERT_EQUAL(2000, length); |
| 80 |
} |
| 81 |
|