From f8c811247c9147020b41b66aa49bb1d297c80537 Mon Sep 17 00:00:00 2001
From: AustinSanders <arsanders@usgs.gov>
Date: Tue, 27 Oct 2020 08:49:59 -0700
Subject: [PATCH] Initial constants unit gtest (#4081)

* Initial constants unit gtest

* removed old test files
---
 isis/src/base/objs/Constants/Constants.truth | 11 -------
 isis/src/base/objs/Constants/unitTest.cpp    | 30 --------------------
 isis/tests/ConstantsTests.cpp                | 29 +++++++++++++++++++
 3 files changed, 29 insertions(+), 41 deletions(-)
 delete mode 100644 isis/src/base/objs/Constants/Constants.truth
 delete mode 100644 isis/src/base/objs/Constants/unitTest.cpp
 create mode 100644 isis/tests/ConstantsTests.cpp

diff --git a/isis/src/base/objs/Constants/Constants.truth b/isis/src/base/objs/Constants/Constants.truth
deleted file mode 100644
index 3863b8da0f..0000000000
--- a/isis/src/base/objs/Constants/Constants.truth
+++ /dev/null
@@ -1,11 +0,0 @@
-Unit test for IsisConstants
-
-3.141592653589793
-1.570796326794897
-2.718281828459045
-0.0174532925199433
-57.29577951308232
-PI/2 radians is 90 degrees
-180 degrees is 3.141592653589793 radians
-
-8
diff --git a/isis/src/base/objs/Constants/unitTest.cpp b/isis/src/base/objs/Constants/unitTest.cpp
deleted file mode 100644
index ee6d494f38..0000000000
--- a/isis/src/base/objs/Constants/unitTest.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <iostream>
-#include <iomanip>
-#include "Constants.h"
-#include "Preference.h"
-
-using namespace std;
-
-int main(int argc, char *argv[]) {
-  Isis::Preference::Preferences(true);
-
-  cout << "Unit test for IsisConstants" << endl;
-
-  cout << setprecision(16) << setw(17) << endl;
-  cout << Isis::PI << endl;
-  cout << Isis::HALFPI << endl;
-  cout << Isis::E << endl;
-  cout << Isis::DEG2RAD << endl;
-  cout << Isis::RAD2DEG << endl;
-  cout << "PI/2 radians is " << Isis::HALFPI *Isis::RAD2DEG << " degrees" << endl;
-  cout << "180 degrees is " << 180 * Isis::DEG2RAD << " radians" << endl << endl;
-
-  cout << sizeof(Isis::BigInt) << endl;
-
-}
-
-
-
-
-
-
diff --git a/isis/tests/ConstantsTests.cpp b/isis/tests/ConstantsTests.cpp
new file mode 100644
index 0000000000..e5df71944a
--- /dev/null
+++ b/isis/tests/ConstantsTests.cpp
@@ -0,0 +1,29 @@
+#include "Constants.h"
+#include <gtest/gtest.h>
+
+TEST (ConstantsTests, TestPi){
+  ASSERT_NEAR(Isis::PI, 3.141592653589793, .000000000000001);
+}
+
+
+TEST (ConstantsTests, TestHalfPi){
+  ASSERT_NEAR(Isis::PI/2, 1.570796326794897, .000000000000001);
+}
+
+TEST (ConstantsTests, TestE){
+  ASSERT_NEAR(Isis::E, 2.718281828459045, .000000000000001);
+}
+
+TEST (ConstantsTests, TestDeg2Rad){
+  ASSERT_NEAR(Isis::DEG2RAD, 0.0174532925199433, .000000000000001);
+  ASSERT_EQ(Isis::DEG2RAD * 180, Isis::PI);
+}
+
+TEST (ConstantsTests, TestRad2Deg){
+  ASSERT_NEAR(Isis::RAD2DEG, 57.29577951308232, .000000000000001);
+  ASSERT_EQ(Isis::RAD2DEG * Isis::PI/2, 90);
+}
+
+TEST (ConstantsTests, TestBigInt){
+  ASSERT_EQ(sizeof(Isis::BigInt), 8);
+}
-- 
GitLab