Mercurial > hg > ltpda
view testing/utp_1.1/generic_utps/utp_generic_aop_negative_tests.m @ 50:7d2e2e065cf1 database-connection-manager
Update unit tests
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 07 Dec 2011 17:24:37 +0100 |
parents | 409a22968d5e |
children |
line wrap: on
line source
% <TestDescription> % % Tests all arithmetic operations which are not allowed. % % </TestDescription> function result = utp_generic_aop_negative_tests(fcn) % <SyntaxDescription> % % Tests all arithmetic operations which are not allowed. % % </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(); % 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(); % 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(); % 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(); % Define check functions result = []; % <AlgoDescription> % % Here we test some negative cases. % % </AlgoDescription> % <AlgoCode> % tsdata <-> fsdata result = [result utp_generic_aop_negative_core(fcn, 'negative test', 'fsdata and tsdata', a_fs, b_ts)]; result = [result utp_generic_aop_negative_core(fcn, 'negative test', 'tsdata and fsdata', a_ts, b_fs)]; % AO with no data field result = [result utp_generic_aop_negative_core(fcn, 'negative test', 'AO no data and tsdata', [a_ts, ao(), b_ts], b_ts)]; result = [result utp_generic_aop_negative_core(fcn, 'negative test', 'tsdata and AO no data', b_ts, [a_ts, ao(), b_ts])]; % % fsdata wrong fs % a = a_fs.setFs(8); % b = b_fs.setFs(9); % result = [result utp_generic_aop_negative_core(fcn, 'negative test', a, b)]; % tsdata wrong fs a = a_ts.setFs(8); b = b_ts.setFs(9); result = [result utp_generic_aop_negative_core(fcn, 'negative test', 'different fs in tsdata', a, b)]; % plus, minus wrong x-units if any(strcmpi(func2str(fcn), {'plus', 'minus'})) a = a_ts.setXunits('m'); b = b_ts.setXunits('Hz'); result = [result utp_generic_aop_negative_core(fcn, 'negative test', 'different x units in tsdata', a, b)]; end % fsdata wrong x-base a = a_fs.setX(1:12); b = b_fs.setX(2:13); result = [result utp_generic_aop_negative_core(fcn, 'negative test', 'different x values in fsdata', a, b)]; % </AlgoCode> % only one input try o = fcn(a_ts); stest = false; catch stest = true; end dbs = dbstack; dbs(1).name = sprintf('%s(negative test)', mfilename); result = [result utp_prepare_result(stest, stest, dbs, mfilename)]; % modifier call try fcn(a_ts); stest = false; catch stest = true; end dbs = dbstack; dbs(1).name = sprintf('%s(negative test)', mfilename); result = [result utp_prepare_result(stest, stest, dbs, mfilename)]; end % END UTP_negative_tests