Mercurial > hg > ltpda
view testing/utp_1.1/generic_utps/utp_64.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 that the contructor properly applies history to the % plist(filename) constructor. % % </TestDescription> function result = utp_64(cl, obj1, ple1, ple2) % <SyntaxDescription> % % Tests that the contructor properly applies history to the % plist(filename) constructor. % % </SyntaxDescription> msg = ''; try % <SyntaxCode> filename1 = 'obj.xml'; filename2 = 'obj.mat'; f1 = feval(cl, obj1); save(f1, filename1); save(f1, filename2); out1 = feval(cl, plist('filename', filename1)); out2 = feval(cl, plist('filename', filename2)); rout1 = out1.rebuild; rout2 = out2.rebuild; % </SyntaxCode> stest = true; catch err msg = err.message; disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the save method doesn't change the input object % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % The load doesn't have two additionally history steps (save + load) if ~eq(out1, f1, ple1) msg = ['The history of the objects are not equal: ' lastwarn]; atest = false; end if ~eq(out2, f1, ple1) msg = ['The history of the objects are not equal: ' lastwarn]; atest = false; end % Rebuild object and check the result if ~eq(rout1, out1, ple2) msg = ['The original and rebuilt objects are not equal: ' lastwarn]; atest = false; end if ~eq(rout2, out2, ple2) msg = ['The original and rebuilt objects are not equal: ' lastwarn]; atest = false; end % </AlgoCode> % delete test file delete(filename1) delete(filename2) 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, msg); end % END UTP_64