From 14f582d1e932eae88953dc6e4ff1cf1ed11a5c12 Mon Sep 17 00:00:00 2001
From: Claudio Mandrioli <claudio.mandrioli@control.lth.se>
Date: Thu, 28 Feb 2019 09:30:15 +0100
Subject: [PATCH] added test case for function gravity

---
 matlab/tests/main_runAllTests.m |  4 ++--
 matlab/tests/test_gravity.m     | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 matlab/tests/test_gravity.m

diff --git a/matlab/tests/main_runAllTests.m b/matlab/tests/main_runAllTests.m
index 3c16658..cf1de78 100644
--- a/matlab/tests/main_runAllTests.m
+++ b/matlab/tests/main_runAllTests.m
@@ -8,8 +8,8 @@ test_get_settings_car
 test_get_settings_cycling
 test_gps_randomized_car
 test_gps_randomized_cycling
-% test_GPSaidedINS_car
-% test_GPSaidedINS_cycling
+test_GPSaidedINS_car
+test_GPSaidedINS_cycling
 % test_gravity
 % test_main_car
 % test_main_cycling
diff --git a/matlab/tests/test_gravity.m b/matlab/tests/test_gravity.m
new file mode 100644
index 0000000..53108ba
--- /dev/null
+++ b/matlab/tests/test_gravity.m
@@ -0,0 +1,25 @@
+% test case for function gravity
+
+%purpose: test that function runs without errors and returns a vector with
+%         magnitude around 9.8
+
+%oracle:  the gravity acceleration is around 9.8
+
+clear all             %clear workspace 
+close all
+cd ..                 %move to functions directory           
+
+%execute function
+rng(1);
+lambda=10*rand(1);
+h=200;
+g=gravity(lambda,h);
+
+cd tests              %go back to tests directory
+
+%verify output
+if ~(abs(9.8-sqrt(g'*g))<=0.2)
+    error('error in function gravity')
+else
+    disp('function gravity ok')
+end
\ No newline at end of file
-- 
GitLab