## Copyright (C) 2018 Jens Ahrensfeld
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see .
## -*- texinfo -*-
## @deftypefn {Function File} {@var{retval} =} test_motor_eval (@var{input1}, @var{input2})
##
## @seealso{}
## @end deftypefn
## Author: Jens Ahrensfeld
## Created: 2018-08-01
function [retval] = test_motor_eval ()
k = 100;
% [cnt, expected]
test_nearest = [ 10 0; 20 0; 49 0; 50 100; 51 100; -10 0; -20 0; -49 0; -50 -100; -51 -100];
test_positive = [ 10 0; 20 0; 49 0; 50 100; 51 100; -10 0; -20 0; -49 0; -50 -100; -51 -100];
test_negative = [ 10 0; 20 0; 49 0; 50 100; 51 100; -10 0; -20 0; -49 0; -50 -100; -51 -100];
disp('Run nearest:')
for i=1:length(test_nearest),
val = test_nearest(i,:)(1);
res_exp = test_nearest(i,:)(2);
result = motor_eval(k, val, 'nearest')
printf("%4u: %f: %f => %f ", i, val, res_exp, result)
if result == res_exp
printf("Pass!\n");
else
printf("Failed!\n");
end
end
disp('Run positive:')
for i=1:length(test_positive),
val = test_positive(i,:)(1);
res_exp = test_positive(i,:)(2);
result = motor_eval(k, val, 'positive')
printf("%4u: %f: %f => %f ", i, val, res_exp, result)
if result == res_exp
printf("Pass!\n");
else
printf("Failed!\n");
end
end
endfunction