view testing/utp_1.1/utps/time/utp_time_string.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents 409a22968d5e
children
line wrap: on
line source

% UTP_TIME_STRING
%
% <MethodDescription>
%
% Test the 'string' method of the time class.
%
% </MethodDescription>
%
% $Id: utp_time_string.m,v 1.2 2011/04/28 07:06:27 hewitson Exp $

function results = utp_time_string(varargin)

  % check inputs
  if nargin == 0

    % some keywords
    class   = 'time';
    mthd    = 'string';

    results = [];
    disp('******************************************************');
    disp(['****  Running UTPs for ' class '/' mthd]);
    disp('******************************************************');

    % get preferences
    results = [results utp_901];

    disp('Done.');
    disp('******************************************************');

  elseif nargin == 1
    % check for UTP functions
    if strcmp(varargin{1}, 'isutp')
      results = 1;
    else
      results = 0;
    end
  else
    error('### Incorrect inputs')
  end

  %% UTP_901

  % <TestDescription>
  %
  % Tests that the output of the 'string' method can be used to recreate the time object.
  %
  % </TestDescription>
  function result = utp_901

    % <SyntaxDescription>
    % Use string to convert a time object to a string. Use eval on the
    % result to recreate a time object.
    % </SyntaxDescription>
    stest = false;
    try
      % <SyntaxCode>
      % create a time object
      t1 = time();
      % obtain its string representation
      str = t1.string();
      % recreate the object from the string
      t2 = eval(str);
      % </SyntaxCode>      
      stest = true;
    end

    atest = true;
    try
      % do not run algorithm tests if sintax tests failed
      assert(stest);
      
      % test that the original and the recreated object are the same
      % <AlgoDescription>
      % Check the recreated time object matches the original.
      % </AlgoDescription>
      % <AlgoCode>
      assert(t1.utc_epoch_milli == t2.utc_epoch_milli);
      % </AlgoCode>
    catch
      atest = false;
    end
    
    % return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end
  
end