Skip to content

Commit 1296406

Browse files
committed
Modification: Functional tests initialized
1 parent 706891e commit 1296406

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "gtest/gtest.h"
2+
3+
#include <PolyUtil.hpp>
4+
5+
6+
TEST(SphericalUtil, computeAngleBetween) {
7+
LatLng up(90, 0);
8+
LatLng down(-90, 0);
9+
LatLng front(0, 0);
10+
LatLng right(0, 90);
11+
LatLng back(0, -180);
12+
LatLng left(0, -90);
13+
14+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(up, up), 0, 1e-6);
15+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(down, down), 0, 1e-6);
16+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(left, left), 0, 1e-6);
17+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(right, right), 0, 1e-6);
18+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(front, front), 0, 1e-6);
19+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(back, back), 0, 1e-6);
20+
21+
// Adjacent vertices
22+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(up, front), M_PI / 2, 1e-6);
23+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(up, right), M_PI / 2, 1e-6);
24+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(up, back), M_PI / 2, 1e-6);
25+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(up, left), M_PI / 2, 1e-6);
26+
27+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(down, front), M_PI / 2, 1e-6);
28+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(down, right), M_PI / 2, 1e-6);
29+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(down, back), M_PI / 2, 1e-6);
30+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(down, left), M_PI / 2, 1e-6);
31+
32+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(back, up), M_PI / 2, 1e-6);
33+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(back, right), M_PI / 2, 1e-6);
34+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(back, down), M_PI / 2, 1e-6);
35+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(back, left), M_PI / 2, 1e-6);
36+
37+
// Opposite vertices
38+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(up, down), M_PI, 1e-6);
39+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(front, back), M_PI, 1e-6);
40+
EXPECT_NEAR(SphericalUtil::computeAngleBetween(left, right), M_PI, 1e-6);
41+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "gtest/gtest.h"
2+
3+
#include <PolyUtil.hpp>
4+
5+
6+
TEST(SphericalUtil, computeDistanceBetween) {
7+
LatLng up(90, 0);
8+
LatLng down(-90, 0);
9+
10+
EXPECT_NEAR(SphericalUtil::computeDistanceBetween(up, down), M_PI * MathUtil::EARTH_RADIUS, 1e-6);
11+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "gtest/gtest.h"
2+
3+
#include <PolyUtil.hpp>
4+
5+
6+
TEST(SphericalUtil, computeHeading) {
7+
LatLng up(90, 0);
8+
LatLng down(-90, 0);
9+
LatLng front(0, 0);
10+
LatLng right(0, 90);
11+
LatLng back(0, -180);
12+
LatLng left(0, -90);
13+
14+
// Opposing vertices for which there is a result
15+
EXPECT_NEAR(SphericalUtil::computeHeading(up, down), -180, 1e-6);
16+
EXPECT_NEAR(SphericalUtil::computeHeading(down, up), 0, 1e-6);
17+
18+
// Adjacent vertices for which there is a result
19+
EXPECT_NEAR(SphericalUtil::computeHeading(front, up), 0, 1e-6);
20+
EXPECT_NEAR(SphericalUtil::computeHeading(right, up), 0, 1e-6);
21+
EXPECT_NEAR(SphericalUtil::computeHeading(back, up), 0, 1e-6);
22+
EXPECT_NEAR(SphericalUtil::computeHeading(down, up), 0, 1e-6);
23+
24+
EXPECT_NEAR(SphericalUtil::computeHeading(front, down), -180, 1e-6);
25+
EXPECT_NEAR(SphericalUtil::computeHeading(right, down), -180, 1e-6);
26+
EXPECT_NEAR(SphericalUtil::computeHeading(back, down), -180, 1e-6);
27+
EXPECT_NEAR(SphericalUtil::computeHeading(left, down), -180, 1e-6);
28+
29+
EXPECT_NEAR(SphericalUtil::computeHeading(right, front), -90, 1e-6);
30+
EXPECT_NEAR(SphericalUtil::computeHeading(left, front), 90, 1e-6);
31+
32+
EXPECT_NEAR(SphericalUtil::computeHeading(front, right), 90, 1e-6);
33+
EXPECT_NEAR(SphericalUtil::computeHeading(back, right), -90, 1e-6);
34+
}

0 commit comments

Comments
 (0)