Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f40e05d

Browse files
committedFeb 8, 2020
Added tests for functions in SphericalUtil class
1 parent 396faa4 commit f40e05d

14 files changed

+88
-51
lines changed
 

‎.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Gtests
2+
Sample
3+
14
## Ignore Visual Studio temporary files, build results, and
25
## files generated by popular Visual Studio add-ons.
36

‎Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sample :
2+
g++ samples/Samples.cpp \
3+
-std=c++14 -Iinclude/ \
4+
-o Sample
5+
6+
gtests :
7+
g++ tests/Tests.cpp \
8+
-std=c++14 -Iinclude/ \
9+
-lgtest -pthread \
10+
-o GTests

‎tests/SphericalUtil/computeOffset.cpp renamed to ‎tests/SphericalUtil/computeOffset.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
#include "SphericalUtil.hpp"
44

5-
inline void EXPECT_NEAR_LatLan(LatLng actual, LatLng expected) {
6-
EXPECT_NEAR(actual.lat, expected.lat, 1e-6);
5+
#define EXPECT_NEAR_LatLan(actual, expected) \
6+
EXPECT_NEAR(actual.lat, expected.lat, 1e-6);
77
// Issue #2
88
// Account for the convergence of longitude lines at the poles
99
// double cosLat = cos(deg2rad(actual.lat));
1010
// EXPECT_NEAR(cosLat * actual.lng, cosLat * expected.lng, 1e-6);
11-
}
1211

1312
TEST(SphericalUtil, computeOffset) {
1413
LatLng up = { 90.0, 0.0 };

‎tests/SphericalUtil/computeOffsetOrigin.cpp renamed to ‎tests/SphericalUtil/computeOffsetOrigin.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
#include "SphericalUtil.hpp"
44

55

6-
inline void EXPECT_NEAR_LatLan(LatLng actual, LatLng expected) {
7-
EXPECT_NEAR(actual.lat, expected.lat, 1e-6);
6+
#define EXPECT_NEAR_LatLan(actual, expected) \
7+
EXPECT_NEAR(actual.lat, expected.lat, 1e-6);
88
// Issue #2
9-
// Account for the convergence of longitude lines at the poles
9+
// Account for the convergence of longitude lines at the poles
1010
// double cosLat = cos(deg2rad(actual.lat));
11-
// EXPECT_NEAR(cosLat * actual.lng, cosLat * expected.lng, 1e-6);
12-
}
11+
// EXPECT_NEAR(cosLat * actual.lng, cosLat * expected.lng, 1e-6);
1312

1413
TEST(SphericalUtil, computeOffsetOrigin) {
1514
LatLng front = { 0.0, 0.0 };

‎tests/SphericalUtil/interpolate.cpp renamed to ‎tests/SphericalUtil/interpolate.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
#include "SphericalUtil.hpp"
44

55

6-
inline void EXPECT_NEAR_LatLan(LatLng actual, LatLng expected) {
6+
#define EXPECT_NEAR_LatLan(actual, expected) \
77
EXPECT_NEAR(actual.lat, expected.lat, 1e-6);
88
// Issue #2
99
// Account for the convergence of longitude lines at the poles
1010
// double cosLat = cos(deg2rad(actual.lat));
1111
// EXPECT_NEAR(cosLat * actual.lng, cosLat * expected.lng, 1e-6);
12-
}
12+
1313

1414
TEST(SphericalUtil, interpolate) {
15-
LatLng up(90, 0);
16-
LatLng down(-90, 0);
17-
LatLng front(0, 0);
18-
LatLng right(0, 90);
19-
LatLng back(0, -180);
20-
LatLng left(0, -90);
15+
LatLng up = { 90.0, 0.0 };
16+
LatLng down = {-90.0, 0.0 };
17+
LatLng front = { 0.0, 0.0 };
18+
LatLng right = { 0.0, 90.0 };
19+
LatLng back = { 0.0, -180.0 };
20+
LatLng left = { 0.0, -90.0 };
2121

2222
EXPECT_NEAR_LatLan(up, SphericalUtil::interpolate(up, up, 1 / 2.0));
2323
EXPECT_NEAR_LatLan(down, SphericalUtil::interpolate(down, down, 1 / 2.0));

‎tests/Tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** Including all tests */
2+
#include "SphericalUtil/interpolate.hpp"
3+
#include "SphericalUtil/computeAngleBetween.hpp"
4+
#include "SphericalUtil/computeSignedArea.hpp"
5+
#include "SphericalUtil/computeArea.hpp"
6+
#include "SphericalUtil/computeLength.hpp"
7+
#include "SphericalUtil/computeOffset.hpp"
8+
#include "SphericalUtil/computeHeading.hpp"
9+
#include "SphericalUtil/computeOffsetOrigin.hpp"
10+
#include "SphericalUtil/computeDistanceBetween.hpp"
11+
12+
13+
int main(int argc, char** argv) {
14+
testing::InitGoogleTest(&argc, argv);
15+
return RUN_ALL_TESTS();
16+
}

‎tests/tests.vcxproj

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,27 @@
3333
<ImportGroup Label="PropertySheets" />
3434
<PropertyGroup Label="UserMacros" />
3535
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
36-
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../geometry-library/</IncludePath>
36+
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../include/</IncludePath>
37+
<Microsoft-googletest-v140-windesktop-msvcstl-static-rt-dyn-Disable-gtest_main>true</Microsoft-googletest-v140-windesktop-msvcstl-static-rt-dyn-Disable-gtest_main>
3738
</PropertyGroup>
3839
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
39-
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../geometry-library/</IncludePath>
40+
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../include/</IncludePath>
41+
<Microsoft-googletest-v140-windesktop-msvcstl-static-rt-dyn-Disable-gtest_main>true</Microsoft-googletest-v140-windesktop-msvcstl-static-rt-dyn-Disable-gtest_main>
4042
</PropertyGroup>
4143
<ItemGroup>
42-
<ClCompile Include="SphericalUtil/computeAngleBetween.cpp" />
43-
<ClCompile Include="SphericalUtil/computeArea.cpp" />
44-
<ClCompile Include="SphericalUtil/computeDistanceBetween.cpp" />
45-
<ClCompile Include="SphericalUtil/computeHeading.cpp" />
46-
<ClCompile Include="SphericalUtil/computeLength.cpp" />
47-
<ClCompile Include="SphericalUtil/computeOffset.cpp" />
48-
<ClCompile Include="SphericalUtil/computeOffsetOrigin.cpp" />
49-
<ClCompile Include="SphericalUtil/computeSignedArea.cpp" />
50-
<ClCompile Include="SphericalUtil/interpolate.cpp" />
44+
<ClInclude Include="SphericalUtil\computeAngleBetween.hpp" />
45+
<ClInclude Include="SphericalUtil\computeArea.hpp" />
46+
<ClInclude Include="SphericalUtil\computeDistanceBetween.hpp" />
47+
<ClInclude Include="SphericalUtil\computeHeading.hpp" />
48+
<ClInclude Include="SphericalUtil\computeLength.hpp" />
49+
<ClInclude Include="SphericalUtil\computeOffset.hpp" />
50+
<ClInclude Include="SphericalUtil\computeOffsetOrigin.hpp" />
51+
<ClInclude Include="SphericalUtil\computeSignedArea.hpp" />
52+
<ClInclude Include="SphericalUtil\interpolate.hpp" />
53+
<ClCompile Include="Tests.cpp" />
5154
</ItemGroup>
5255
<ItemGroup>
53-
<ProjectReference Include="..\geometry-library\geometry-library.vcxproj">
56+
<ProjectReference Include="..\include\geometry-library.vcxproj">
5457
<Project>{6ff667f1-262a-4779-81cf-fd346fe2af62}</Project>
5558
</ProjectReference>
5659
</ItemGroup>
@@ -82,14 +85,16 @@
8285
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
8386
<ClCompile>
8487
<PrecompiledHeader>NotUsing</PrecompiledHeader>
85-
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
88+
<PrecompiledHeaderFile>
89+
</PrecompiledHeaderFile>
8690
<Optimization>Disabled</Optimization>
8791
<PreprocessorDefinitions>X64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
8892
<MinimalRebuild>true</MinimalRebuild>
8993
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
9094
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
9195
<WarningLevel>Level3</WarningLevel>
9296
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);$(SolutionDir)/include/</AdditionalIncludeDirectories>
97+
<PrecompiledHeaderOutputFile />
9398
</ClCompile>
9499
<Link>
95100
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -116,12 +121,14 @@
116121
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
117122
<ClCompile>
118123
<PrecompiledHeader>NotUsing</PrecompiledHeader>
119-
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
124+
<PrecompiledHeaderFile>
125+
</PrecompiledHeaderFile>
120126
<PreprocessorDefinitions>X64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
121127
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
122128
<WarningLevel>Level3</WarningLevel>
123129
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
124130
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories);$(SolutionDir)/include/</AdditionalIncludeDirectories>
131+
<PrecompiledHeaderOutputFile />
125132
</ClCompile>
126133
<Link>
127134
<GenerateDebugInformation>true</GenerateDebugInformation>

‎tests/tests.vcxproj.filters

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,38 @@
66
</Filter>
77
</ItemGroup>
88
<ItemGroup>
9-
<ClCompile Include="SphericalUtil/computeAngleBetween.cpp">
9+
<ClCompile Include="Tests.cpp" />
10+
</ItemGroup>
11+
<ItemGroup>
12+
<None Include="packages.config" />
13+
</ItemGroup>
14+
<ItemGroup>
15+
<ClInclude Include="SphericalUtil\computeAngleBetween.hpp">
1016
<Filter>SphericalUtil</Filter>
11-
</ClCompile>
12-
<ClCompile Include="SphericalUtil/computeDistanceBetween.cpp">
17+
</ClInclude>
18+
<ClInclude Include="SphericalUtil\computeArea.hpp">
1319
<Filter>SphericalUtil</Filter>
14-
</ClCompile>
15-
<ClCompile Include="SphericalUtil/computeHeading.cpp">
20+
</ClInclude>
21+
<ClInclude Include="SphericalUtil\computeDistanceBetween.hpp">
1622
<Filter>SphericalUtil</Filter>
17-
</ClCompile>
18-
<ClCompile Include="SphericalUtil/computeOffset.cpp">
23+
</ClInclude>
24+
<ClInclude Include="SphericalUtil\computeHeading.hpp">
1925
<Filter>SphericalUtil</Filter>
20-
</ClCompile>
21-
<ClCompile Include="SphericalUtil/computeOffsetOrigin.cpp">
26+
</ClInclude>
27+
<ClInclude Include="SphericalUtil\computeLength.hpp">
2228
<Filter>SphericalUtil</Filter>
23-
</ClCompile>
24-
<ClCompile Include="SphericalUtil/interpolate.cpp">
29+
</ClInclude>
30+
<ClInclude Include="SphericalUtil\computeOffset.hpp">
2531
<Filter>SphericalUtil</Filter>
26-
</ClCompile>
27-
<ClCompile Include="SphericalUtil/computeLength.cpp">
32+
</ClInclude>
33+
<ClInclude Include="SphericalUtil\computeOffsetOrigin.hpp">
2834
<Filter>SphericalUtil</Filter>
29-
</ClCompile>
30-
<ClCompile Include="SphericalUtil/computeArea.cpp">
35+
</ClInclude>
36+
<ClInclude Include="SphericalUtil\computeSignedArea.hpp">
3137
<Filter>SphericalUtil</Filter>
32-
</ClCompile>
33-
<ClCompile Include="SphericalUtil/computeSignedArea.cpp">
38+
</ClInclude>
39+
<ClInclude Include="SphericalUtil\interpolate.hpp">
3440
<Filter>SphericalUtil</Filter>
35-
</ClCompile>
36-
</ItemGroup>
37-
<ItemGroup>
38-
<None Include="packages.config" />
41+
</ClInclude>
3942
</ItemGroup>
4043
</Project>

0 commit comments

Comments
 (0)
Please sign in to comment.