view testing/utp_1.1/generic_utps/utp_generic_aop_rule9.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents
children
line wrap: on
line source


% <TestDescription>
%
% Tests the arithmetic operators rule 9.
%
% </TestDescription>
function result = utp_generic_aop_rule9(fcn)
  
  % <SyntaxDescription>
  %
  % Tests the arithmetic operators rule 9 for each data type: xydata,
  % fsdata, tsdata, cdata and useful combinations.
  %
  % </SyntaxDescription>
  
  % Test AOs
  % tsdata
  n = 12;
  fs = 12.1;
  x = 0:(1/fs):(n/fs)-1/fs;
  a_ts = ao(x,randn(n,1), fs);
  a_ts.setDx(ones(n,1)*1.1);
  a_ts.setDy((1:n)*2.2);
  a_ts.setYunits('Hz^(-1/2) V^2');
  a_ts.setName();
  
  b_ts = ao(x,randn(n,1), fs);
  b_ts.setDx(7);
  b_ts.setDy(9);
  b_ts.setYunits('Hz^(-1/2) V^2');
  b_ts.setName();
  
  H_NQ_ts = [copy(a_ts, 1), copy(a_ts, 1); copy(b_ts, 1), copy(a_ts, 1)];
  M_NP_ts = [copy(a_ts, 1), copy(a_ts, 1), copy(b_ts, 1); copy(b_ts, 1), copy(a_ts, 1), copy(a_ts, 1)];
  
  % fsdata
  a_fs = ao(plist('xvals', 1:n, 'yvals', abs(randn(n,1)), 'type', 'fsdata'));
  a_fs.setDx(ones(n,1)*1.1);
  a_fs.setDy((1:n)*2.2);
  a_fs.setName();
  
  b_fs = ao(plist('xvals', 1:n, 'yvals', abs(randn(n,1)), 'type', 'fsdata'));
  b_fs.setDx(7);
  b_fs.setDy(9);
  b_fs.setName();
  
  H_NQ_fs = [copy(a_fs, 1), copy(a_fs, 1); copy(b_fs, 1), copy(a_fs, 1)];
  M_NP_fs = [copy(a_fs, 1), copy(a_fs, 1), copy(b_fs, 1); copy(b_fs, 1), copy(a_fs, 1), copy(a_fs, 1)];
  
  % xydata
  a_xy = ao(plist('xvals', 1:n, 'yvals', abs(randn(n,1)), 'type', 'xydata'));
  a_xy.setDx(ones(n,1)*1.1);
  a_xy.setDy((1:n)*2.2);
  a_xy.setYunits('Hz^(-1/2) V^2');
  a_xy.setName();
  
  b_xy = ao(plist('xvals', 1:n, 'yvals', abs(randn(n,1)), 'type', 'xydata'));
  b_xy.setDx(7);
  b_xy.setDy(9);
  b_xy.setName();
  
  H_NQ_xy = [copy(a_xy, 1), copy(a_xy, 1); copy(b_xy, 1), copy(a_xy, 1)];
  M_NP_xy = [copy(a_xy, 1), copy(a_xy, 1), copy(b_xy, 1); copy(b_xy, 1), copy(a_xy, 1), copy(a_xy, 1)];
  
  % cdata
  a_c = ao(8);
  a_c.setDy(2);
  a_c.setName();
  
  b_c = ao(111:122);
  b_c.setDy((111:122)/100);
  b_c.setName();
  
  H_NQ_c = [copy(a_c, 1), copy(a_c, 1); copy(b_c, 1), copy(a_c, 1)];
  M_NP_c = [copy(a_c, 1), copy(a_c, 1), copy(b_c, 1); copy(b_c, 1), copy(a_c, 1), copy(a_c, 1)];
  
  % Define check functions
  
  result = [];
  
  % <AlgoDescription>
  %
  % Here we test  element-wise operator rule9 as in S2-AEI-TN-3059.
  %
  % 1) Check the data type of the resulting object.
  % 2) Check the resulting object contains the correct values.
  % 3) Check the error propagation.
  % 4) Check the units of the output object.
  % 5) Check the resulting object can be rebuilt.
  %
  % </AlgoDescription>
  
  
  % <AlgoCode>
  % tsdata
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxP tsdata and NxQ tsdata', M_NP_ts, H_NQ_ts)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxQ tsdata and NxP tsdata', H_NQ_ts, M_NP_ts)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxP tsdata and NxQ xydata', M_NP_ts, H_NQ_xy)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxQ xydata and NxP tsdata', H_NQ_xy, M_NP_ts)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxP tsdata and NxQ cdata', M_NP_ts, H_NQ_c)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxQ cdata and NxP tsdata', H_NQ_c, M_NP_ts)];
  
  % fsdata
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxP fsdata and NxQ fsdata', M_NP_fs, H_NQ_fs)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxQ fsdata and NxP fsdata', H_NQ_fs, M_NP_fs)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxP fsdata and NxQ xydata', M_NP_fs, H_NQ_xy)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxQ xydata and NxP fsdata', H_NQ_xy, M_NP_fs)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxP fsdata and NxQ cdata', M_NP_fs, H_NQ_c)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxQ cdata and NxP fsdata', H_NQ_c, M_NP_fs)];
  
  % xydata
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxP xydata and NxQ xydata', M_NP_xy, H_NQ_xy)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxQ xydata and NxP xydata', H_NQ_xy, M_NP_xy)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxP xydata and NxQ cdata', M_NP_xy, H_NQ_c)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxQ cdata and NxP xydata', H_NQ_c, M_NP_xy)];
  
  % cdata
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxP cdata and NxQ cdata', M_NP_c, H_NQ_c)];
  result = [result utp_generic_aop_negative_core(fcn, 'rule9', 'NxQ cdata and NxP cdata', H_NQ_c, M_NP_c)];
  % </AlgoCode>
  
end % END UTP_rule3