From 3ab2b2b7a825708d65fb377b039511ccf37e89ee Mon Sep 17 00:00:00 2001 From: Claudio Mandrioli <claudio.mandrioli@control.lth.se> Date: Thu, 28 Feb 2019 09:07:36 +0100 Subject: [PATCH] added test cases for function GPS_aidedINS both car trace and cycling trace --- matlab/tests/main_runAllTests.m | 4 ++-- matlab/tests/test_GPSaidedINS_car.m | 32 +++++++++++++++++++++++++ matlab/tests/test_GPSaidedINS_cycling.m | 32 +++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 matlab/tests/test_GPSaidedINS_car.m create mode 100644 matlab/tests/test_GPSaidedINS_cycling.m diff --git a/matlab/tests/main_runAllTests.m b/matlab/tests/main_runAllTests.m index 44d4333..3c16658 100644 --- a/matlab/tests/main_runAllTests.m +++ b/matlab/tests/main_runAllTests.m @@ -6,8 +6,8 @@ test_dcm2q test_get_settings_car test_get_settings_cycling -% test_gps_randomized_car -% test_gps_randomized_cycling +test_gps_randomized_car +test_gps_randomized_cycling % test_GPSaidedINS_car % test_GPSaidedINS_cycling % test_gravity diff --git a/matlab/tests/test_GPSaidedINS_car.m b/matlab/tests/test_GPSaidedINS_car.m new file mode 100644 index 0000000..aae6a5b --- /dev/null +++ b/matlab/tests/test_GPSaidedINS_car.m @@ -0,0 +1,32 @@ +% test case for function GPSaidedINS_car + +%purpose: test that the function runs without errors and outputs the +% correct struct + +%oracle: returns a non-empty struct with fields: x_h, delta_u_h, diag_P, +% energy and error + +clear all %clear workspace +close all +cd .. %move to functions directory + +%initialize input data +load('car_input_data.mat'); +settings=get_settings_car(); +settings.P_treshold=4.1; +%execute function +out_data=GPSaidedINS_car(in_data,settings); + +cd tests %go back to tests directory + +%verify output +if ~(isfield(out_data, 'x_h') && ... + isfield(out_data, 'delta_u_h') && ... + isfield(out_data, 'diag_P') && ... + isfield(out_data, 'energy') && ... + isfield(out_data, 'error')... + ) + error('error in function GPSaidedINS_car') +else + disp('function GPSaidedINS_car ok') +end \ No newline at end of file diff --git a/matlab/tests/test_GPSaidedINS_cycling.m b/matlab/tests/test_GPSaidedINS_cycling.m new file mode 100644 index 0000000..016fc9b --- /dev/null +++ b/matlab/tests/test_GPSaidedINS_cycling.m @@ -0,0 +1,32 @@ +% test case for function GPSaidedINS_cycling + +%purpose: test that the function runs without errors and outputs the +% correct struct + +%oracle: returns a non-empty struct with fields: x_h, delta_u_h, diag_P, +% energy and error + +clear all %clear workspace +close all +cd .. %move to functions directory + +%initialize input data +load('cycling_input_data.mat'); +settings=get_settings_cycling(); +settings.P_treshold=4.1; +%execute function +out_data=GPSaidedINS_cycling(in_data,settings); + +cd tests %go back to tests directory + +%verify output +if ~(isfield(out_data, 'x_h') && ... + isfield(out_data, 'delta_u_h') && ... + isfield(out_data, 'diag_P') && ... + isfield(out_data, 'energy') && ... + isfield(out_data, 'error')... + ) + error('error in function GPSaidedINS_cycling') +else + disp('function GPSaidedINS_cycling ok') +end \ No newline at end of file -- GitLab