Mercurial > hg > ltpda
diff testing/utp_1.1/generic_utps/utp_genericModify.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_genericModify.m Tue Dec 06 18:42:11 2011 +0100 @@ -0,0 +1,67 @@ +% <TestDescription> +% +% Tests that the <METHOD> method can modify the input AO. +% +% </TestDescription> +function result = utp_genericModify(method, obj, args, algo, ple) + + % <SyntaxDescription> + % + % Test that the <METHOD> method can modify the input object by calling + % with no output and that the method doesn't change the input of the + % function notation (with a equal sign). + % + % </SyntaxDescription> + + try + % <SyntaxCode> + obj_modi = copy(obj,1); + obj_eq = copy(obj,1); + if iscell(args) + out = feval(method, obj_eq, args{:}); + feval(method, obj_modi, args{:}); + else + out = feval(method, obj_eq, args); + feval(method, obj_modi, args); + end + % </SyntaxCode> + stest = true; + catch err + disp(err.message) + stest = false; + end + + % <AlgoDescription> + % + % 1) Check that the modified input is changed by the method + % 2) Check that 'out' and 'obj_eq' are now different. + % 3) Check that 'obj_eq' is not changed + % 4) Check that out and amodi are the same + % + % </AlgoDescription> + + atest = true; + if stest + % <AlgoCode> + % Check that obj_modi is changed + atest = algo(obj, obj_modi, 1, args); + % Check that 'out' and 'obj_eq' are now different. + if eq(out, obj_eq, ple), atest = false; end + % Check that 'obj_eq' is not changed + if ~eq(obj_eq, obj, ple), atest = false; end + % Check that out and obj_modi are the same + if ~eq(out, obj_modi, ple), atest = false; end + + % </AlgoCode> + else + atest = false; + end + + % Return a result structure + result = utp_prepare_result(atest, stest, dbstack, ['utp_' class(obj) '_' method]); +end + + + + +