Skip to content
Snippets Groups Projects
Verified Commit 3bc9997a authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Added unit test.

parent c9cf1a3c
Branches
No related tags found
No related merge requests found
......@@ -3,12 +3,12 @@ function m = strings(o) % --*-- Unitary tests --*--
% Returns a cell array of strings containing the dates
%
% INPUTS
% - o [dates] object with n elements.
% - o [dates] object with n elements.
%
% OUTPUTS
% - m [cell of char] object with n elements.
% Copyright (C) 2013-2017 Dynare Team
% Copyright (C) 2013-2020 Dynare Team
%
% This code is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
......@@ -29,26 +29,53 @@ for i = 1:o.length()
m(i) = { date2string(o.time(i,:), o.freq) };
end
return
%@test:1
%$ % Define a dates objects
%$ d = dates('1950Q1'):dates('1950Q3');
%$
%$ % Call the tested routine.
%$ try
%$ m = strings(d);
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ % Check the results.
%$ if t(1)
%$ t(2) = iscell(m);
%$ t(3) = dassert(m{1}, '1950Q1');
%$ t(4) = dassert(m{2}, '1950Q2');
%$ t(5) = dassert(m{3}, '1950Q3');
%$ t(6) = dassert(length(m), 3);
%$ end
%$
%$ T = all(t);
% Define a dates objects
d = dates('1950Q1'):dates('1950Q3');
% Call the tested routine.
try
m = strings(d);
t(1) = true;
catch
t(1) = false;
end
% Check the results.
if t(1)
t(2) = iscell(m);
t(3) = dassert(m{1}, '1950Q1');
t(4) = dassert(m{2}, '1950Q2');
t(5) = dassert(m{3}, '1950Q3');
t(6) = dassert(length(m), 3);
end
T = all(t);
%@eof:1
%@test:2
% Define a dates objects
d = dates('2000-01-01'):dates('2000-01-03');
% Call the tested routine.
try
m = strings(d);
t(1) = true;
catch
t(1) = false;
end
% Check the results.
if t(1)
t(2) = iscell(m);
t(3) = dassert(m{1}, '2000-01-01');
t(4) = dassert(m{2}, '2000-01-02');
t(5) = dassert(m{3}, '2000-01-03');
t(6) = dassert(length(m), 3);
end
T = all(t);
%@eof:2
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment