diff --git a/src/@dates/strings.m b/src/@dates/strings.m index 5557c1429993f908c6c0e9d01aa488f409d9ccee..b872e55591d28e5cc9a2bd36e5fa5faa8e8773b6 100644 --- a/src/@dates/strings.m +++ b/src/@dates/strings.m @@ -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