view testing/utp_1.1/utps/pest/utp_pest_setModels.m @ 49:0bcdf74587d1 database-connection-manager

Cleanup
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:24:36 +0100
parents 409a22968d5e
children
line wrap: on
line source

% UTP_PEST_SETMODELS a set of UTPs for the pest/setModels method
%
% M Hewitson 06-08-08
%
% $Id: utp_pest_setModels.m,v 1.3 2011/04/06 19:14:54 ingo Exp $
%

% <MethodDescription>
%
% The setModels method of the pest class sets the models property.
%
% </MethodDescription>

function results = utp_pest_setModels(varargin)
  
  % Check the inputs
  if nargin == 0
    
    % Some keywords
    class   = 'pest';
    mthd    = 'setModels';
    prop    = 'models';
    
    disp('******************************************************');
    disp(['****  Running UTPs for ' class '/' mthd]);
    disp('******************************************************');
    
    % Test objects
    pe1 = pest([8, 9]);
    pe1.setName;
    pe2 = pest([1 2]);
    pe2.setName;
    pe3 = pe1;
    
    pev = [pe1, pe2, pe1];
    pem = [pe1, pe2, pe1; pe1, pe2, pe1];
    
    % Exception list for the UTPs:
    [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
    
    % The setter method have different possibilities to set a property
    val1 = smodel('a+b');
    val2 = plist(prop, smodel('a+b'));
    
    % Run the general tests
    results(1) = utp_genericSet_minfo(mthd, pe1, prop, @algoTests_minfo);           % test getInfo call
    results(2) = utp_genericAnyShape(mthd, pev, val1, @algoTests);                  % test vector
    results(3) = utp_genericAnyShape(mthd, pev, val2, @algoTests);                  % test vector call with plist
    results(4) = utp_genericAnyShapeInternal(mthd, pev, val1, @algoTestsInternal);  % test internal vector call
    results(5) = utp_genericAnyShape(mthd, pem, val1, @algoTests);                  % test matrix call
    results(6) = utp_genericAnyShape(mthd, pem, val2, @algoTests);                  % test matrix call with plist
    results(7) = utp_genericAnyShapeInternal(mthd, pem, val1, @algoTestsInternal);  % test internal matrix call
    results(8) = utp_genericList(mthd, pe1, pe2, pe3, val1, @algoTests);            % test list
    results(9) = utp_genericList(mthd, pe1, pe2, pe3, val2, @algoTests);            % test list with plist
    results(10) = utp_genericList(mthd, pe1, pev, pem, val1, @algoTests);           % test mixed shape of input objs
    results(11) = utp_genericHistory(mthd, pe1, val1, ple2);                        % test the history
    results(12) = utp_genericModify(mthd, pe1, val1, @algoTests, ple1);             % test the modifier call
    results(13) = utp_genericOutput(mthd, pe1, pe2, val1, @algoTests, ple2);        % test the outputs
    
    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
  
  % Check that the default value un the PLIST
  function atest = algoTests_minfo(defVal)
    atest = true;
    % Check default value for the key 'models'
    if ~eq(defVal, []), atest = false; end
  end
  
  % Check that the property have the correct value
  function atest = algoTests(in, out, idx, value)
    atest = true;
    % Check that the input and output objects are the same except the
    % property 'models' and the history
    ple = plist('EXCEPTIONS', {'created', 'proctime', 'UUID', 'hist', prop});
    if ~eq(in(idx), out(idx), ple), atest = false; end
    if ~eq(in(idx).hist, out(idx).hist.inhists), atest = false; end
    % Check that the parameter gets the correct value.
    if isa(value, 'plist') && value.nparams == 1 && value.isparam(prop)
      % The value was set with a plist.
      if ~eq(out(idx).(prop), value.find(prop), ple1), atest = false; end
    else
      if ~eq(out(idx).(prop), value, ple1), atest = false; end
    end
  end
  
  % Check that the property have the correct value for an internal call
  function atest = algoTestsInternal(in, out, idx, value)
    atest = true;
    % Check that the input and output objects are the same except the
    % property 'models' and the history
    ple = plist('EXCEPTIONS', {'created', 'proctime', 'UUID', prop});
    if ~eq(in(idx), out(idx), ple), atest = false; end
    % Check that the parameter gets the correct value.
    if ~eq(out(idx).(prop), value, ple1), atest = false; end
  end
  
  
end