Mercurial > hg > ltpda
diff testing/utp_1.1/generic_utps/utp_09.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 diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testing/utp_1.1/generic_utps/utp_09.m Tue Dec 06 18:42:11 2011 +0100 @@ -0,0 +1,85 @@ +% <TestDescription> +% +% Test the shape of the data in AOs. +% +% </TestDescription> +function result = utp_09(method, obj1, obj2) + + % <SyntaxDescription> + % + % Test that the <METHOD> method keeps the data shape of the input object. The + % input AO data must be an array with row data and/or column data. + % + % </SyntaxDescription> + + try + % <SyntaxCode> + + if iscolumnvector(obj1) == iscolumnvector(obj2) + warning('!!! Incorrect inputs. Give a column and a row vector.'); + stest = false; + else + out1 = feval(method, obj1); + out2 = feval(method, obj2); + % </SyntaxCode> + stest = true; + end + + catch err + disp(err.message) + stest = false; + end + + % <AlgoDescription> + % + % 1) Check that the shape of the data doesn't change. + % + % </AlgoDescription> + + atest = true; + if stest + % <AlgoCode> + % Check the shape of the output data + + atest = false; + + if iscolumnvector(out1) && iscolumnvector(obj1) + atest = true; + end + + if isrowvector(out1) && isrowvector(obj1) + atest = true; + end + + + % </AlgoCode> + else + atest = false; + end + + % Return a result structure + dd = dbstack; + mfilename = dd(2).file(1:end-2); + result = utp_prepare_result(atest, stest, dbstack, mfilename); +end % END UTP_09 + +function res = iscolumnvector(obj) + + if size(obj.data.y, 1)>=1 && size(obj.data.y,2)==1 + res = true; + else + res = false; + end + +end + + +function res = isrowvector(obj) + + if size(obj.data.y, 2)>=1 && size(obj.data.y,1)==1 + res = true; + else + res = false; + end + +end