view testing/utp_1.1/utps/ao/utp_ao_join_tsdata.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

% UTP_AO_JOIN a set of UTPs for the ao/join method
%
% M Hewitson 06-08-08
%
% $Id: utp_ao_join_tsdata.m,v 1.12 2011/11/06 06:46:21 mauro Exp $
%

% <MethodDescription>
%
% The join method of the ao class join multiple AOs into a single AO. This
% UTP join only analysis objects with tsdata. The other data objects will
% be tested in an other UTP.
%
% </MethodDescription>

function results = utp_ao_join_tsdata(varargin)
  
  % Check the inputs
  if nargin == 0
    
    % Some keywords
    class   = 'ao';
    mthd    = 'join';
    
    results = [];
    disp('******************************************************');
    disp(['****  Running UTPs for ' class '/' mthd]);
    disp('******************************************************');
    
    % Exception list for the UTPs:
    [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
    
    % Run the tests
    results = [results utp_01];    % getInfo call
    results = [results utp_02];    % Vector input
    results = [results utp_03];    % Matrix input
    results = [results utp_04];    % List input
    results = [results utp_05];    % Test with mixed input
    results = [results utp_06];    % Test history is working
    results = [results utp_07];    % Test the modify call works
    results = [results utp_08];    % Test with additional plist with the key 'axis'
    results = [results utp_09];    % Test input data shape == output data shape
    results = [results utp_10];    % Test the x-values
    
    a1 = ao(0:29, randn(30,1), 1);
    a2 = ao(0:29, randn(30,1), 1);
    a1.setT0('2009-02-12 14:00:00');
    a2.setT0('2009-02-12 14:00:35');
    
    results = [results utp_11(mthd, [a1 a2], ple1)];    % Test plotinfo doesn't disappear
    
    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_01
  
  % <TestDescription>
  %
  % Tests that the getInfo call works for this method.
  %
  % </TestDescription>
  function result = utp_01
    
    
    % <SyntaxDescription>
    %
    % Test that the getInfo call works for no sets, all sets, and each set
    % individually.
    %
    % </SyntaxDescription>
    
    try
      % <SyntaxCode>
      % Call for no sets
      io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
      % Call for all sets
      io(2) = eval([class '.getInfo(''' mthd ''')']);
      % Call for each set
      for kk=1:numel(io(2).sets)
        io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
      end
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check that getInfo call returned an minfo object in all cases.
    % 2) Check that all plists have the correct parameters.
    %
    % </AlgoDescription>
    
    atest = true;
    if stest
      % <AlgoCode>
      % check we have minfo objects
      if isa(io, 'minfo')
        %%% SET 'None'
        if ~isempty(io(1).sets), atest = false; end
        if ~isempty(io(1).plists), atest = false; end
        %%% Check all Sets
        if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end
        if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
        %%%%%%%%%%   SET 'Default'
        if io(3).plists.nparams ~= 3, atest = false; end
        % Check key
        if ~io(3).plists.isparam('zerofill'), atest = false; end
        if ~io(3).plists.isparam('sameT0'), atest = false; end
        if ~io(3).plists.isparam('fstol'), atest = false; end
        % Check default value
        if ~isequal(io(3).plists.find('zerofill'), 'no'), atest = false; end
        if ~isequal(io(3).plists.find('samet0'), 'no'), atest = false; end
        if ~isequal(io(3).plists.find('fstol'), 1e-6), atest = false; end
        % Check options
        if ~isequal(io(3).plists.getOptionsForParam('zerofill'), {'yes', 'no'}), atest = false; end
        if ~isequal(io(3).plists.getOptionsForParam('samet0'), {'yes', 'no'}), atest = false; end
        if ~isequal(io(3).plists.getOptionsForParam('fstol'), {1e-6}), atest = false; end
      end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_01
  
  %% UTP_02
  
  % <TestDescription>
  %
  % Tests that the join method works with a vector of AOs as input.
  %
  % </TestDescription>
  function result = utp_02
    
    % <SyntaxDescription>
    %
    % Test that the join method works for a vector of AOs as input.
    %
    % </SyntaxDescription>
    
    try
      % <SyntaxCode>
      a1 = ao(0:29, randn(30,1), 1);
      a2 = ao(0:29, randn(30,1), 1);
      a3 = ao(0:29, randn(30,1), 1);
      a1.setT0('2009-02-12 14:00:00');
      a2.setT0('2009-02-12 14:00:35');
      a3.setT0('2009-02-12 14:00:20');
      avec = [a1, a2, a3];
      out  = join(avec);
      mout = rebuild(out);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check that the output is exact one AO.
    % 2) Check that the output have the correct data.
    % 3) Check the re-built object
    %
    % </AlgoDescription>
    
    atest = true;
    if stest
      % <AlgoCode>
      % Check we have the correct number of outputs
      if numel(out) ~= 1, atest = false; end
      % Compute reference data
      % Toff is the smallest t0. Here t0 of a1 -> '2009-02-12 14:00:00'
      Toff = time('2009-02-12 14:00:00').double;
      
      % Vector of input aos is sorted based on the t0 value
      t0s = avec.t0.double;
      [~, idx] = sort(t0s);
      
      t0 = avec(idx(1)).t0.double - Toff;
      x0 = avec(idx(1)).x + t0;
      y0 = avec(idx(1)).data.getY;
      for kk = 2:numel(avec)
        t0 = avec(idx(kk)).t0.double - Toff;
        x  = avec(idx(kk)).x + t0;
        y  = avec(idx(kk)).y;
        idxPost = find(x > max(x0));
        idxPre  = find(x < min(x0));
        x0 = [x(idxPre); x0; x(idxPost)];
        y0 = [y(idxPre); y0; y(idxPost)];
      end
      if ~isequal(out.x, x0), atest = false; end
      if ~isequal(out.y, y0), atest = false; end
      if ~isequal(out.t0.double, Toff), atest = false; end
      if ~eq(out, mout, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_02
  
  %% UTP_03
  
  % <TestDescription>
  %
  % Tests that the join method works with a matrix of AOs as input.
  %
  % </TestDescription>
  function result = utp_03
    
    % <SyntaxDescription>
    %
    % Test that the join method works for a matrix of AOs as input.
    %
    % </SyntaxDescription>
    
    try
      % <SyntaxCode>
      a1 = ao(0:29, randn(30,1), 1);
      a2 = ao(0:29, randn(30,1), 1);
      a3 = ao(0:29, randn(30,1), 1);
      a4 = ao(0:29, randn(30,1), 1);
      a5 = ao(0:29, randn(30,1), 1);
      a6 = ao(0:29, randn(30,1), 1);
      a1.setT0('2009-02-12 14:01:00');
      a2.setT0('2009-02-12 14:00:20');
      a3.setT0('2009-02-12 14:00:00');
      a4.setT0('2009-02-12 14:00:50');
      a5.setT0('2009-02-12 14:01:50');
      a6.setT0('2009-02-12 14:02:00');
      amat = [a1, a2, a3];
      out  = join(amat);
      mout = rebuild(out);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check that the output is exact one AO.
    % 2) Check that the output have the correct data.
    % 3) Check the re-built object
    %
    % </AlgoDescription>
    
    atest = true;
    if stest
      % <AlgoCode>
      % Check we have the correct number of outputs
      if numel(out) ~= 1, atest = false; end
      % Compute reference data
      % Toff is the smallest t0. Here t0 of a1 -> '2009-02-12 14:00:00'
      Toff = time('2009-02-12 14:00:00').double;
      
      % Matrix of input aos is sorted based on the t0 value
      t0s = amat.t0.double;
      [~, idx] = sort(t0s);
      
      t0 = amat(idx(1)).t0.double - Toff;
      x0 = amat(idx(1)).x + t0;
      y0 = amat(idx(1)).data.getY;
      for kk = 2:numel(amat)
        t0 = amat(idx(kk)).t0.double - Toff;
        x  = amat(idx(kk)).x + t0;
        y  = amat(idx(kk)).y;
        idxPost = find(x > max(x0));
        idxPre  = find(x < min(x0));
        x0 = [x(idxPre); x0; x(idxPost)];
        y0 = [y(idxPre); y0; y(idxPost)];
      end
      if ~isequal(out.x, x0), atest = false; end
      if ~isequal(out.y, y0), atest = false; end
      if ~isequal(out.t0.double, Toff), atest = false; end
      if ~eq(out, mout, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_03
  
  %% UTP_04
  
  % <TestDescription>
  %
  % Tests that the join method works with a list of AOs as input.
  %
  % </TestDescription>
  function result = utp_04
    
    % <SyntaxDescription>
    %
    % Tests that the join method works with a list of AOs as input.
    %
    % </SyntaxDescription>
    
    try
      % <SyntaxCode>
      a1 = ao(0:29, randn(30,1), 1);
      a2 = ao(0:29, randn(30,1), 1);
      a3 = ao(0:29, randn(30,1), 1);
      a1.setT0('2009-02-12 14:01:00');
      a2.setT0('2009-02-12 14:00:30');
      a3.setT0('2009-02-12 14:00:00');
      out  = join(a1, a2, a3);
      mout = rebuild(out);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check that the output is exact one AO.
    % 2) Check that the output have the correct data.
    % 3) Check the re-built object
    %
    % </AlgoDescription>
    
    atest = true;
    aoin  = [a1 a2 a3];
    if stest
      % <AlgoCode>
      % Check we have the correct number of outputs
      if numel(out) ~= 1, atest = false; end
      % Compute reference data
      % Toff is the smallest t0. Here t0 of a1 -> '2009-02-12 14:00:00'
      Toff = time('2009-02-12 14:00:00').double;
      
      % List of input aos is sorted based on the t0 value
      t0s = aoin.t0.double;
      [~, idx] = sort(t0s);
      
      t0 = aoin(idx(1)).t0.double - Toff;
      x0 = aoin(idx(1)).x + t0;
      y0 = aoin(idx(1)).data.getY;
      for kk = 2:numel(aoin)
        t0 = aoin(idx(kk)).t0.double - Toff;
        x  = aoin(idx(kk)).x + t0;
        y  = aoin(idx(kk)).y;
        idxPost = find(x > max(x0));
        idxPre  = find(x < min(x0));
        x0 = [x(idxPre); x0; x(idxPost)];
        y0 = [y(idxPre); y0; y(idxPost)];
      end
      if ~isequal(out.x, x0), atest = false; end
      if ~isequal(out.y, y0), atest = false; end
      if ~isequal(out.t0.double, Toff), atest = false; end
      if ~eq(out, mout, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_04
  
  %% UTP_05
  
  % <TestDescription>
  %
  % Tests that the join method works with a mix of different shaped AOs as
  % input.
  %
  % </TestDescription>
  function result = utp_05
    
    % <SyntaxDescription>
    %
    % Tests that the join method works with a mix of different shaped AOs
    % as input.
    %
    % </SyntaxDescription>
    
    try
      % <SyntaxCode>
      a1 = ao(0:29, randn(30,1), 1);
      a2 = ao(0:29, randn(30,1), 1);
      a3 = ao(0:29, randn(30,1), 1);
      a4 = ao(0:29, randn(30,1), 1);
      a1.setT0('2009-02-12 14:01:00');
      a2.setT0('2009-02-12 14:00:20');
      a3.setT0('2009-02-12 14:00:00');
      a4.setT0('2009-02-12 14:00:50');
      out  = join(a1, [a2 a3], a4);
      mout = rebuild(out);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check that the output is exact one AO.
    % 2) Check that the output have the correct data.
    % 3) Check the re-built object
    %
    % </AlgoDescription>
    
    atest = true;
    aoin  = [a1, a2, a3, a4];
    if stest
      % <AlgoCode>
      % Check we have the correct number of outputs
      if numel(out) ~= 1, atest = false; end
      % Compute reference data
      % Toff is the smallest t0. Here t0 of a1 -> '2009-02-12 14:00:00'
      Toff = time('2009-02-12 14:00:00').double;
      
      % Matrix of input aos is sorted based on the t0 value
      t0s = aoin.t0.double;
      [~, idx] = sort(t0s);
      
      t0 = aoin(idx(1)).t0.double - Toff;
      x0 = aoin(idx(1)).x + t0;
      y0 = aoin(idx(1)).data.getY;
      for kk = 2:numel(aoin)
        t0 = aoin(idx(kk)).t0.double - Toff;
        x  = aoin(idx(kk)).x + t0;
        y  = aoin(idx(kk)).y;
        idxPost = find(x > max(x0));
        idxPre  = find(x < min(x0));
        x0 = [x(idxPre); x0; x(idxPost)];
        y0 = [y(idxPre); y0; y(idxPost)];
      end
      if ~isequal(out.x, x0), atest = false; end
      if ~isequal(out.y, y0), atest = false; end
      if ~isequal(out.t0.double, Toff), atest = false; end
      if ~eq(out, mout, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_05
  
  %% UTP_06
  
  % <TestDescription>
  %
  % Tests that the join method properly applies history.
  %
  % </TestDescription>
  function result = utp_06
    
    % <SyntaxDescription>
    %
    % Test that the result of applying the join method can be processed back.
    %
    % </SyntaxDescription>
    
    try
      % <SyntaxCode>
      a1 = ao(0:29, randn(30,1), 1);
      a2 = ao(0:29, randn(30,1), 1);
      a1.setT0('2009-02-12 14:00:00');
      a2.setT0('2009-02-12 14:00:35');
      
      out  = join(a1, a2);
      mout = rebuild(out);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check that the last entry in the history of 'out' corresponds to
    %    'join'.
    % 2) Check that the re-built object is the same object as the input.
    %
    % </AlgoDescription>
    
    atest = true;
    if stest
      % <AlgoCode>
      % Check the last step in the history of 'out'
      if ~strcmp(out.hist.methodInfo.mname, 'join'), atest = false; end
      % The rebuilt object must be the same as 'out'
      if ~eq(mout, out, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_06
  
  %% UTP_07
  
  % <TestDescription>
  %
  % Tests that the join method can modify the input AO.
  %
  % </TestDescription>
  function result = utp_07
    
    % <SyntaxDescription>
    %
    % Test that the join method can modify the input AO 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>
      % copy at1 to work with
      a1 = ao(0:29, randn(30,1), 1);
      a2 = ao(0:29, randn(30,1), 1);
      a1.setT0('2009-02-12 14:00:00');
      a2.setT0('2009-02-12 14:00:25');
      
      amodi = ao(a1);
      aeq   = ao(a1);
      out = aeq.join(a2);
      amodi.join(a2);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check that 'out' and 'aeq' are now different.
    % 2) Check that 'aeq' is not changed
    % 3) Check that the modified input is joined
    % 4) Check that out and amodi are the same
    %
    % </AlgoDescription>
    
    atest = true;
    if stest
      % <AlgoCode>
      % Check that 'out' and 'aeq' are now different.
      if eq(out, aeq, ple2), atest = false; end
      % Check that 'aeq' is not changed
      if ~eq(aeq, ao(a1), ple1), atest = false; end
      % Check that the modified input is joined
      Toff = time('2009-02-12 14:00:00').double;
      
      t0 = amodi.t0.double - Toff;
      x0 = amodi.x + t0;
      y0 = amodi.data.getY;
      t0 = a2.t0.double - Toff;
      x  = a2.x + t0;
      y  = a2.y;
      idxPost = find(x > max(x0));
      idxPre  = find(x < min(x0));
      x0 = [x(idxPre); x0; x(idxPost)];
      y0 = [y(idxPre); y0; y(idxPost)];
      if ~isequal(amodi.x, x0), atest = false; end
      if ~isequal(amodi.y, y0), atest = false; end
      if ~isequal(amodi.t0.double, Toff), atest = false; end
      % Check that out and amodi are the same
      if ~eq(out, amodi, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_07
  
  %% UTP_08
  
  % <TestDescription>
  %
  % Test that the join method fills the gaps with zeros.
  %
  % </TestDescription>
  function result = utp_08
    
    % <SyntaxDescription>
    %
    % Test that the join method fills the gaps with zeros.
    %
    % </SyntaxDescription>
    
    try
      % <SyntaxCode>
      n = 29;
      fs = 3;
      x = 0:(1/fs):(n/fs)-1/fs;
      a1 = ao(x, randn(n,1), fs);
      a2 = ao(x, randn(n,1), fs);
      a3 = ao(x, randn(n,1), fs);
      a1.setT0('2009-02-12 14:00:00');
      a2.setT0('2009-02-12 14:00:35');
      a3.setT0('2009-02-12 14:01:15');
      pl = plist('zerofill', true);
      
      out1  = join(a1, a2, pl);
      out2  = join(a1, a2, a3, pl);
      mout1 = rebuild(out1);
      mout2 = rebuild(out2);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check that the join method filled the gaps with zero
    % 2) Check that the re-built objects are the same as out[1..2]
    %
    % </AlgoDescription>
    
    atest = true;
    TOL   = 1e-13;
    if stest
      % <AlgoCode>
      % Check 'out1'
      Toff = time('2009-02-12 14:00:00').double;
      t0 = a1.t0.double - Toff;
      x0 = a1.x + t0;
      y0 = a1.data.getY;
      t0 = a2.t0.double - Toff;
      x  = a2.x + t0;
      y  = a2.y;
      idxPost = find(x > max(x0));
      idxPre  = find(x < min(x0));
      x0 = [x(idxPre); x0; x(idxPost)];
      y0 = [y(idxPre); y0; y(idxPost)];
      % Look for gaps
      d = diff(x0);
      gap = find(d >= 2*1/a1.fs);
      xgap = linspace(x0(gap)+1/a1.fs, x0(gap+1)-1/a1.fs, (x0(gap+1)-x0(gap))*a1.fs-2*1/a1.fs).';
      ygap = zeros(length(xgap),1);
      x0   = [x0(1:gap); xgap; x0(gap+1:end)];
      y0   = [y0(1:gap); ygap; y0(gap+1:end)];
      if any(abs(out1.x - x0) > TOL ), atest = false; end
      if ~isequal(out1.y, y0), atest = false; end
      
      % Check 'out2'
      Toff = time('2009-02-12 14:00:00').double;
      t0 = a1.t0.double - Toff;
      x0 = a1.x + t0;
      y0 = a1.data.getY;
      % Join a2
      t0 = a2.t0.double - Toff;
      x  = a2.x + t0;
      y  = a2.y;
      idxPost = find(x > max(x0));
      idxPre  = find(x < min(x0));
      x0 = [x(idxPre); x0; x(idxPost)];
      y0 = [y(idxPre); y0; y(idxPost)];
      % Look for gaps
      d = diff(x0);
      gap = find(d >= 2*1/a1.fs);
      xgap = linspace(x0(gap)+1/a1.fs, x0(gap+1)-1/a1.fs, (x0(gap+1)-x0(gap))*a1.fs-2*1/a1.fs).';
      ygap = zeros(length(xgap),1);
      x0   = [x0(1:gap); xgap; x0(gap+1:end)];
      y0   = [y0(1:gap); ygap; y0(gap+1:end)];
      % Join a3
      t0 = a3.t0.double - Toff;
      x  = a3.x + t0;
      y  = a3.y;
      idxPost = find(x > max(x0));
      idxPre  = find(x < min(x0));
      x0 = [x(idxPre); x0; x(idxPost)];
      y0 = [y(idxPre); y0; y(idxPost)];
      % Look for gaps
      d = diff(x0);
      gap = find(d >= 2*1/a1.fs);
      xgap = linspace(x0(gap)+1/a1.fs, x0(gap+1)-1/a1.fs, (x0(gap+1)-x0(gap))*a1.fs-2*1/a1.fs).';
      ygap = zeros(length(xgap),1);
      x0   = [x0(1:gap); xgap; x0(gap+1:end)];
      y0   = [y0(1:gap); ygap; y0(gap+1:end)];
      if any(abs(out2.x - x0) > TOL ), atest = false; end
      if ~isequal(out2.y, y0), atest = false; end
      
      % Check out[1..2]
      if ~eq(mout1, out1, ple2), atest = false; end
      if ~eq(mout2, out2, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_08
  
  %% UTP_09
  
  % <TestDescription>
  %
  % Test the shape of the output.
  %
  % </TestDescription>
  function result = utp_09
    
    % <SyntaxDescription>
    %
    % Test that the join method keeps the data shape of the input object.
    % The input AO must be an AO with row data and an AO with column data.
    %
    % </SyntaxDescription>
    
    try
      % <SyntaxCode>
      a1 = ao([0:29 30:49], randn(50,1), 1);
      a2 = ao([20:49 50:69], randn(1,50), 1);
      a1.setT0('2009-02-12 14:00:00');
      a2.setT0('2009-02-12 14:00:00');
      
      out1  = join(a1, a2);
      out2  = join(a2, a1);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check that the shape of the data doesn't change.
    %
    % </AlgoDescription>
    
    atest = true;
    if stest
      % <AlgoCode>
      % Check the shape of the output data
      if size(out1.data.y, 1) == 1, atest = false; end
      if size(out2.data.y, 2) == 1, atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_09
  
  %% UTP_10
  
  % <TestDescription>
  %
  % Test the x-values.
  %
  % </TestDescription>
  function result = utp_10
    
    % <SyntaxDescription>
    %
    % Test the x-values.
    %
    % </SyntaxDescription>
    
    try
      % <SyntaxCode>
      a1 = ao(1:20, randn(20,1), plist('type', 'tsdata'));
      a2 = ao(11:30, randn(20,1), plist('type', 'tsdata'));
      a3 = ao(41:50, randn(10,1), plist('type', 'tsdata'));
      
      out1  = join(a1, a2, a3, plist('zerofill', 'no'));
      out2  = join(a1, a2, a3, plist('zerofill', 'yes'));
      out3  = join(a2, a1, a3, plist('zerofill', 'no'));
      out4  = join(a2, a1, a3, plist('zerofill', 'yes'));
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end
    
    % <AlgoDescription>
    %
    % 1) Check the x-values for the case where we 'zerofill' or not.
    % 2) Compare the outputs to see that switching the order did not matter,
    %    because if the different t0 of the data, that get sorted anyways.
    %
    % </AlgoDescription>
    
    atest = true;
    if stest
      % <AlgoCode>
      % Check the x-getter of the AO
      if ~isequal(out1.x, [1:30, 41:50]'), atest = false; end
      if ~isequal(out2.x, [1:50]'), atest = false; end
      if ~isequal(out3.x, [1:30, 41:50]'), atest = false; end
      if ~isequal(out4.x, [1:50]'), atest = false; end
      % Check the real stored x values
      if ~isequal(out1.data.x, [0:29, 40:49]') || ~isequal(out1.data.toffset, 1000), atest = false; end
      if ~isempty(out2.data.x), atest = false; end
      if ~isequal(out3.data.x, [0:29, 40:49]') || ~isequal(out3.data.toffset, 1000), atest = false; end
      if ~isempty(out4.data.x), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end
    
    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_10
  
end