const double X = 12.345678;
const double Y = -89.765432;
+const double ORIGIN = 1000;
+const double DELTA = 500;
+
class TestSceneCoordinate : public QObject
{
Q_OBJECT
private Q_SLOTS:
+ void azimuthTo();
+ void azimuthTo_data();
void constructors();
void conversion();
void conversion_data();
}
}
+void TestSceneCoordinate::azimuthTo()
+{
+ QFETCH(SceneCoordinate, to);
+ QFETCH(qreal, expectedAzimuth);
+
+ SceneCoordinate from(ORIGIN, ORIGIN);
+
+ QCOMPARE(from.azimuthTo(to), expectedAzimuth);
+}
+
+void TestSceneCoordinate::azimuthTo_data()
+{
+ QTest::addColumn<SceneCoordinate>("to");
+ QTest::addColumn<qreal>("expectedAzimuth");
+
+ QTest::newRow("N") << SceneCoordinate(ORIGIN, ORIGIN - DELTA) << 0.0;
+ QTest::newRow("NE") << SceneCoordinate(ORIGIN + DELTA, ORIGIN - DELTA) << 45.0;
+ QTest::newRow("E") << SceneCoordinate(ORIGIN + DELTA, ORIGIN) << 90.0;
+ QTest::newRow("SE") << SceneCoordinate(ORIGIN + DELTA, ORIGIN + DELTA) << 135.0;
+ QTest::newRow("S") << SceneCoordinate(ORIGIN, ORIGIN + DELTA) << 180.0;
+ QTest::newRow("SW") << SceneCoordinate(ORIGIN - DELTA, ORIGIN + DELTA) << 225.0;
+ QTest::newRow("W") << SceneCoordinate(ORIGIN - DELTA, ORIGIN) << 270.0;
+ QTest::newRow("NW") << SceneCoordinate(ORIGIN - DELTA, ORIGIN - DELTA) << 315.0;
+}
+
void TestSceneCoordinate::constructors()
{
SceneCoordinate coordinate;