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

Added unit tests.

parent 25eefcff
Branches
Tags
No related merge requests found
function f = firstdate(o) function f = firstdate(o) % --*-- Unitary tests --*--
% Copyright (C) 2014 Dynare Team % Copyright (C) 2016 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -18,3 +18,19 @@ function f = firstdate(o) ...@@ -18,3 +18,19 @@ function f = firstdate(o)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
f = o.dates(1); f = o.dates(1);
%@test:1
%$ try
%$ ts = dseries(randn(10, 3),'1938Q3');
%$ dd = ts.firstdate();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ if t(1)
%$ t(2) = isequal(dd, dates('1938Q3'));
%$ end
%$
%$ T = all(t);
%@eof:1
function b = isnan(o) function b = isnan(o) % --*-- Unitary tests --*--
% Returns an array of logicals (true/false). Element (t,i) is true iff the i-th variable at % Returns an array of logicals (true/false). Element (t,i) is true iff the i-th variable at
% period number t is not a NaN. % period number t is not a NaN.
...@@ -28,3 +28,24 @@ function b = isnan(o) ...@@ -28,3 +28,24 @@ function b = isnan(o)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
b = isnan(o.data); b = isnan(o.data);
%@test:1
%$ try
%$ data = randn(100, 10);
%$ cnan = randi(10, 50, 1);
%$ rnan = randi(100, 50, 1);
%$ for i=1:50, data(rnan(i),cnan(i)) = NaN; end
%$ inan = isnan(data);
%$ ts = dseries(data);
%$ dd = ts.isnan();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ if t(1)
%$ t(2) = isequal(dd, inan);
%$ end
%$
%$ T = all(t);
%@eof:1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment