Mercurial > hg > ltpda
view testing/utp_1.1/generic_utps/utp_generic_aop_rule3.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 3. % % </TestDescription> function result = utp_generic_aop_rule3(fcn) % <SyntaxDescription> % % Tests the arithmetic operators rule 3 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(); V_N_ts = [copy(a_ts, 1), copy(a_ts, 1), copy(b_ts, 1)]; V_M_ts = [copy(a_ts, 1), copy(b_ts, 1), copy(a_ts, 1), copy(b_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(); V_N_fs = [copy(a_fs, 1), copy(a_fs, 1), copy(b_fs, 1)]; V_M_fs = [copy(a_fs, 1), copy(b_fs, 1), copy(a_fs, 1), copy(b_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(); V_N_xy = [copy(a_xy, 1), copy(a_xy, 1), copy(b_xy, 1)]; V_M_xy = [copy(a_xy, 1), copy(b_xy, 1), copy(a_xy, 1), copy(b_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(); V_N_c = [copy(a_c, 1), copy(a_c, 1), copy(b_c, 1)]; V_M_c = [copy(a_c, 1), copy(b_c, 1), copy(a_c, 1), copy(b_c, 1)]; % Define check functions result = []; % <AlgoDescription> % % Here we test element-wise operator rule3 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, 'rule3', 'vector tsdata and vector tsdata', V_M_ts, V_N_ts)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector tsdata and vector tsdata', V_N_ts, V_M_ts)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector tsdata and vector xydata', V_N_ts, V_M_xy)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector xydata and vector tsdata', V_N_xy, V_M_ts)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector tsdata and vector cdata', V_N_ts, V_M_c)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector cdata and vector tsdata', V_N_c, V_M_ts)]; % fsdata result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector fsdata and vector fsdata', V_M_fs, V_N_fs)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector fsdata and vector fsdata', V_N_fs, V_M_fs)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector fsdata and vector xydata', V_N_fs, V_M_xy)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector xydata and vector fsdata', V_N_xy, V_M_fs)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector fsdata and vector cdata', V_N_fs, V_M_c)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector cdata and vector fsdata', V_N_c, V_M_fs)]; % xydata result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector xydata and vector xydata', V_M_xy, V_N_xy)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector xydata and vector xydata', V_N_xy, V_M_xy)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector xydata and vector cdata', V_N_xy, V_M_c)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector cdata and vector xydata', V_N_c, V_M_xy)]; % cdata result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector cdata and vector cdata', V_M_c, V_N_c)]; result = [result utp_generic_aop_negative_core(fcn, 'rule3', 'vector cdata and vector cdata', V_N_c, V_M_c)]; % </AlgoCode> end % END UTP_rule3