aboutsummaryrefslogtreecommitdiff
path: root/unittests/autodeclination_test.cpp
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2015-01-05 10:02:07 +0100
committerThomas Gubler <thomasgubler@gmail.com>2015-01-05 10:02:07 +0100
commit16b9f666e790a2b939f7890b39cc6e4cf2552165 (patch)
treeee936b06d15e75e12b175f6786772781aff32cd8 /unittests/autodeclination_test.cpp
parente16c4ff76e7eff2da88bcbef5d05dd4ba11e7203 (diff)
parentc3ed35f5cc8e2617e61747e904dbaa652d1cc2c8 (diff)
downloadpx4-firmware-16b9f666e790a2b939f7890b39cc6e4cf2552165.tar.gz
px4-firmware-16b9f666e790a2b939f7890b39cc6e4cf2552165.tar.bz2
px4-firmware-16b9f666e790a2b939f7890b39cc6e4cf2552165.zip
Merge remote-tracking branch 'upstream/master' into dev_ros
Conflicts: src/lib/mathlib/math/Matrix.hpp src/modules/mc_att_control/mc_att_control_main.cpp src/modules/uORB/topics/vehicle_status.h src/platforms/px4_includes.h
Diffstat (limited to 'unittests/autodeclination_test.cpp')
-rw-r--r--unittests/autodeclination_test.cpp53
1 files changed, 9 insertions, 44 deletions
diff --git a/unittests/autodeclination_test.cpp b/unittests/autodeclination_test.cpp
index 1bda6eb79..a27d5f100 100644
--- a/unittests/autodeclination_test.cpp
+++ b/unittests/autodeclination_test.cpp
@@ -1,52 +1,17 @@
-
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
-#include <math.h>
-#include <systemlib/mixer/mixer.h>
-#include <systemlib/err.h>
+#include <unistd.h>
+
#include <drivers/drv_hrt.h>
-#include <px4iofirmware/px4io.h>
-// #include "../../src/systemcmds/tests/tests.h"
#include <geo/geo.h>
+#include <px4iofirmware/px4io.h>
+#include <systemlib/err.h>
+#include <systemlib/mixer/mixer.h>
-int main(int argc, char *argv[]) {
- warnx("autodeclination test started");
-
- char* latstr = 0;
- char* lonstr = 0;
- char* declstr = 0;
-
- if (argc < 4) {
- warnx("Too few arguments. Using default lat / lon and declination");
- latstr = "47.0";
- lonstr = "8.0";
- declstr = "0.6";
- } else {
- latstr = argv[1];
- lonstr = argv[2];
- declstr = argv[3];
- }
-
- char* p_end;
-
- float lat = strtod(latstr, &p_end);
- float lon = strtod(lonstr, &p_end);
- float decl_truth = strtod(declstr, &p_end);
-
- float declination = get_mag_declination(lat, lon);
-
- printf("lat: %f lon: %f, expected dec: %f, estimated dec: %f\n", lat, lon, declination, decl_truth);
-
- int ret = 0;
-
- // Fail if the declination differs by more than one degree
- float decldiff = fabs(decl_truth - declination);
- if (decldiff > 0.5f) {
- warnx("declination differs more than 1 degree: difference: %12.8f", decldiff);
- ret = 1;
- }
+#include "gtest/gtest.h"
- return ret;
+TEST(AutoDeclinationTest, AutoDeclination) {
+ ASSERT_NEAR(get_mag_declination(47.0, 8.0), 0.6, 0.5) << "declination differs more than 1 degree";
}