diff m-toolbox/test/repo_tests/test_timespan.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/test/repo_tests/test_timespan.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,52 @@
+function test_timespan(varargin)
+% A test function to submit a timespan to the repository. The timespan is then
+% retrieved and compared to the original one.
+% 
+% Usage: test_timespan()     - connects to Hannover repository
+%        test_timespan(conn) - connects to the repository specified by
+%                                  the database conn object.
+% 
+% M Hewitson 24-02-08
+% 
+% $Id: test_timespan.m,v 1.7 2008/11/14 09:51:55 hewitson Exp $
+% 
+
+if nargin == 0
+  conn = utils.mysql.connect('130.75.117.67', 'ltpda_test');
+else
+  conn = varargin{1};
+end
+
+%% Submit a timeformat
+t1 = time();
+t2 = t1 + 100;
+
+p = timespan(t1, t2);
+
+sinfo.conn                   = conn;
+sinfo.experiment_title       = 'submit timespan';
+sinfo.experiment_description = 'this is just a test of the whole thing';
+sinfo.analysis_description   = 'just submitting';
+sinfo.quantity               = 'none';
+sinfo.keywords               = 'none';
+sinfo.reference_ids          = '1,2';
+sinfo.additional_comments    = 'none';
+sinfo.additional_authors     = 'no one';
+
+[ids, cid] = submit(p, sinfo);
+
+%% Retrieve the object
+
+q = timespan(plist('conn', conn, 'cid', cid))
+
+%% Close connection
+if nargin == 0
+  close(conn);
+end
+
+
+%% Test
+
+if ne(p,q,'hist')
+  error('### timespan objects are not the same.')
+end