From b0503906bd34a8807b42d36bf2ef24192e779f91 Mon Sep 17 00:00:00 2001
From: Claudio Mandrioli <claudio.mandrioli@control.lth.se>
Date: Wed, 27 Feb 2019 19:44:27 +0100
Subject: [PATCH] added test case for function gps_randomized_car

---
 matlab/tests/main_runAllTests.m        |  4 ++--
 matlab/tests/test_dcm2q.m              |  6 +++--
 matlab/tests/test_gps_randomized_car.m | 32 ++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 4 deletions(-)
 create mode 100644 matlab/tests/test_gps_randomized_car.m

diff --git a/matlab/tests/main_runAllTests.m b/matlab/tests/main_runAllTests.m
index c5e7161..44d4333 100644
--- a/matlab/tests/main_runAllTests.m
+++ b/matlab/tests/main_runAllTests.m
@@ -4,8 +4,8 @@
 
 % every time a new test-case is define simply add it here
 test_dcm2q
-% test_get_settings_car
-% test_get_settings_cycling
+test_get_settings_car
+test_get_settings_cycling
 % test_gps_randomized_car
 % test_gps_randomized_cycling
 % test_GPSaidedINS_car
diff --git a/matlab/tests/test_dcm2q.m b/matlab/tests/test_dcm2q.m
index a48088c..2017d1d 100644
--- a/matlab/tests/test_dcm2q.m
+++ b/matlab/tests/test_dcm2q.m
@@ -5,15 +5,17 @@
 
 %oracle:  easy to chekc from the formulae
 
-clear all
+clear all             %clear workspace 
 close all
-cd ..
+cd ..                 %move to functions directory           
 
+%execute function
 R=zeros(4,4);
 q=dcm2q(R);
 
 cd tests
 
+%verify output
 if q~=[0;0;0;0.5]
     error('error in function dcm_2q')
 else
diff --git a/matlab/tests/test_gps_randomized_car.m b/matlab/tests/test_gps_randomized_car.m
new file mode 100644
index 0000000..1daa01d
--- /dev/null
+++ b/matlab/tests/test_gps_randomized_car.m
@@ -0,0 +1,32 @@
+% test case for function gps_randomized_car
+
+%purpose: verify that the transition turn_on is taken from initial state
+
+%oracle:  
+
+clear all             %clear workspace 
+close all
+cd ..                 %move to functions directory           
+
+%initialize input data
+sensor.state='no_info';
+sensor.fetchfp=1.0;
+sensor.geteph=Inf;
+sensor.ephExp=1800.0;
+sensor.fp=0;
+sensor.eph=5;
+turn=true;
+time=0;
+sv=5;
+%execute function
+sensor=gps_randomized_car(time,sensor,turn,sv);
+
+
+cd tests              %go back to tests directory
+
+%verify output
+if ~(strcmp(sensor.state,'cold_start'))
+    error('error in function gps_randomized_car')
+else
+    disp('function gps_randomized_car ok')
+end
\ No newline at end of file
-- 
GitLab