Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sébastien Villemot
dseries
Commits
ef59f538
Commit
ef59f538
authored
Oct 16, 2017
by
Stéphane Adjemian
Committed by
Stéphane Adjemian
Nov 08, 2017
Browse files
Added unitary tests for X13 class.
parent
0ab5d352
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/@x13/clean.m
View file @
ef59f538
function
clean
(
o
)
function
clean
(
o
)
% --*-- Unitary tests --*--
% Erase generated files if any.
...
...
@@ -20,4 +20,19 @@ function clean(o)
if
~
isempty
(
o
.
results
)
basename
=
o
.
results
.
name
;
delete
(
sprintf
(
'%s.*'
,
basename
))
end
\ No newline at end of file
end
%@test:1
%$ try
%$ series = dseries(rand(100,1),'1999M1');
%$ o = x13(series);
%$ o.x11('save','(d11)');
%$ o.run();
%$ o.clean();
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
src/@x13/print.m
View file @
ef59f538
function
basename
=
print
(
o
,
basename
)
function
basename
=
print
(
o
,
basename
)
% --*-- Unitary tests --*--
% Prints spc file.
...
...
@@ -352,7 +352,7 @@ if ismember('x11regression', o.commands)
for
i
=
1
:
length
(
conditionningvariables
)
if
~
ismember
(
conditionningvariables
{
i
},
o
.
x
.
name
)
fclose
(
fid
);
error
(
'x13:x11regression: Variable %s is unk
o
nwn'
,
conditionningvariables
{
i
})
error
(
'x13:x11regression: Variable %s is unkn
o
wn'
,
conditionningvariables
{
i
})
end
end
% Select the data.
...
...
@@ -390,4 +390,35 @@ if ismember('x11regression', o.commands)
fprintf
(
fid
,
'}\n\n'
);
end
fclose
(
fid
);
\ No newline at end of file
fclose
(
fid
);
%@test:1
%$ try
%$ series = dseries(rand(100,1),'1999M1');
%$ o = x13(series);
%$ o.x11('save','(d11)');
%$ o.automdl('savelog','amd','mixed','no');
%$ o.outlier('types','all','save','(fts)');
%$ o.check('maxlag',24,'save','(acf pcf)');
%$ o.estimate('save','(mdl est)');
%$ o.forecast('maxlead',18,'probability',0.95,'save','(fct fvr)');
%$ o.run(); % necessary to invoke alphanumeric "basename"
%$ o.print();
%$
%$ text = fileread(sprintf('%$s.spc',o.results.name));
%$ comm = o.commands;
%$
%$ for i = 1:numel(comm)
%$ ex(i,1) = ~isempty(strfind(text,[comm{i} ' {']));
%$ end
%$
%$ if all(ex)
%$ t(1) = true;
%$ o.clean();
%$ end
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
src/@x13/subsasgn.m
View file @
ef59f538
function
val
=
subsasgn
(
val
,
idx
,
rhs
)
function
val
=
subsasgn
(
val
,
idx
,
rhs
)
% --*-- Unitary tests --*--
% Copyright (C) 2017 Dynare Team
%
...
...
@@ -16,3 +16,33 @@ function val = subsasgn(val, idx, rhs)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
error
(
'Members of x13 class are private'
)
%@test:1
%$ t = zeros(3,1);
%$
%$ y = dseries(rand(100,1),'1999M1');
%$ o = x13(y);
%$
%$ try
%$ o.commands = {'yes','no','maybe'};
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ try
%$ o.results = 'Perverse string';
%$ t(2) = false;
%$ catch
%$ t(2) = true;
%$ end
%$
%$ try
%$ o.y = dseries(rand(100,1));
%$ t(3) = false;
%$ catch
%$ t(3) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
src/@x13/subsref.m
View file @
ef59f538
function
o
=
subsref
(
o
,
S
)
function
o
=
subsref
(
o
,
S
)
% --*-- Unitary tests --*--
% Overloads the subsref method.
...
...
@@ -93,4 +93,47 @@ switch S(1).type
end
otherwise
error
(
'x13:: I do not understand what you are asking for!'
)
end
\ No newline at end of file
end
%@test:1
%$ t = zeros(1,5);
%$ o = x13();
%$
%$ try
%$ o(arima);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ try
%$ o.unicorn;
%$ t(2) = false;
%$ catch
%$ t(2) = true;
%$ end
%$
%$ try
%$ o.x11('onearg','onevalue','twoargs');
%$ t(3) = false;
%$ catch
%$ t(3) = true;
%$ end
%$
%$ try
%$ o.x11('unicorn','yes please');
%$ o.x11.unicorn;
%$ t(4) = false;
%$ catch
%$ t(4) = true;
%$ end
%$
%$ try
%$ o.print.unicorn;
%$ t(5) = false;
%$ catch
%$ t(5) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
src/@x13/x13.m
View file @
ef59f538
classdef
x13
<
handle
classdef
x13
<
handle
% --*-- Unitary tests --*--
% Class for X13 toolbox.
...
...
@@ -118,4 +118,42 @@ methods
end
end
end
\ No newline at end of file
end
%@test:1
%$
%$ try
%$ series = dseries(rand(100,2),'1999M1');
%$ o = x13(series);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
%@test:2
%$ try
%$ series = rand(100,2);
%$ o = x13(series);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:2
%@test:3
%$ try
%$ y = dseries(rand(100,1),'1999M1');
%$ x = rand(100,2);
%$ o = x13(y,x);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:3
\ No newline at end of file
src/utilities/x13/checkcommandcompatibility.m
View file @
ef59f538
function
checkcommandcompatibility
(
o
,
comm
)
function
checkcommandcompatibility
(
o
,
comm
)
% --*-- Unitary tests --*--
% Checks for compatibility of X13 commands.
...
...
@@ -37,4 +37,28 @@ switch comm
error
(
'x13:pickmdl: PICKMDL command is not compatible with AUTOMDL command!'
)
end
otherwise
end
\ No newline at end of file
end
%@test:1
%$ t = zeros(2,1);
%$
%$ series = dseries(rand(100,1),'1999M1');
%$ o = x13(series);
%$ o.arima('save','(d11)');
%$
%$ try
%$ o.automdl('savelog','amd');
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ try
%$ o.pickmdl('savelog','amd');
%$ t(2) = false;
%$ catch
%$ t(2) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
src/utilities/x13/checkoptioncompatibility.m
View file @
ef59f538
function
checkoptioncompatibility
(
o
)
function
checkoptioncompatibility
(
o
)
% --*-- Unitary tests --*--
% Checks for compatibility of options in different X13 commands.
...
...
@@ -35,4 +35,35 @@ if ~isempty(o.estimate.file)
elseif
ismember
(
'pickmdl'
,
o
.
commands
)
error
(
'Command PICKMDL not compatible with ESTIMATE.file option!'
);
end
end
\ No newline at end of file
end
%@test:1
%$ t = zeros(3,1);
%$
%$ series = dseries(rand(100,1),'1999M1');
%$ o = x13(series);
%$ o.estimate('file','test');
%$
%$ try
%$ o.arima('model','(1 0 1)');
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ try
%$ o.pickmdl('savelog','amd');
%$ t(2) = false;
%$ catch
%$ t(2) = true;
%$ end
%$
%$ try
%$ o.regression('b',0.9);
%$ t(3) = false;
%$ catch
%$ t(3) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
src/utilities/x13/isoption.m
View file @
ef59f538
function
b
=
isoption
(
command
,
option
)
function
b
=
isoption
(
command
,
option
)
% --*-- Unitary tests --*--
% Copyright (C) 2017 Dynare Team
%
...
...
@@ -78,3 +78,21 @@ switch command
otherwise
error
(
'x13:isoption: Unknown block!'
)
end
%@test:1
%$ try
%$ b = isoption('unicorn','horse sounds');
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
%@test:2
%$ b = isoption('arima','ar');
%$ c = ~isoption('arima','unicorn');
%$
%$ T = all([b;c]);
%@eof:2
\ No newline at end of file
src/utilities/x13/printoption.m
View file @
ef59f538
function
printoption
(
fid
,
optname
,
optvalue
)
function
printoption
(
fid
,
optname
,
optvalue
)
% --*-- Unitary tests --*--
% Copyright (C) 2017 Dynare Team
%
...
...
@@ -41,4 +41,21 @@ elseif isreal(optvalue)
error
(
'This option value type is not implemented!'
);
end
end
end
\ No newline at end of file
end
%@test:1
%$ fid = fopen('test.spc', 'w');
%$
%$ try
%$ series = dseries(rand(100,1),'1999M1');
%$ o = x13(series);
%$ o.x11('save','(d11)');
%$ optnames = fieldnames(o.x11);
%$ printoption(fid,'mode',o.x11.mode);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
src/utilities/x13/printspan.m
View file @
ef59f538
function
printspan
(
fid
,
period1
,
period2
)
function
printspan
(
fid
,
period1
,
period2
)
% --*-- Unitary tests --*--
% Copyright (C) 2017 Dynare Team
%
...
...
@@ -37,4 +37,46 @@ switch period1.freq
fprintf
(
fid
,
' span = (%i,%i)\n'
,
period1
.
year
,
period2
.
year
);
otherwise
error
(
'x13:regression: This is a bug! Please contact the authors.'
)
end
\ No newline at end of file
end
%@test:1
%$ try
%$ per1 = dates(52,1996,1);
%$ per2 = dates(52,1996,2);
%$ fid = fopen('test.spc', 'w');
%$ printstart(fid,per1,per2);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
%@test:2
%$ try
%$ per1 = dates(52,1996,1);
%$ per2 = dates(52,1994,2);
%$ fid = fopen('test.spc', 'w');
%$ printstart(fid,per1,per2);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:2
%@test:3
%$ try
%$ per1 = dates(4,1996,1);
%$ per2 = dates(52,1996,2);
%$ fid = fopen('test.spc', 'w');
%$ printstart(fid,per1,per2);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:3
\ No newline at end of file
src/utilities/x13/printstart.m
View file @
ef59f538
function
printstart
(
fid
,
period
)
function
printstart
(
fid
,
period
)
% --*-- Unitary tests --*--
% Copyright (C) 2017 Dynare Team
%
...
...
@@ -29,4 +29,17 @@ switch period.freq
fprintf
(
fid
,
' start = %i\n'
,
period
.
year
);
otherwise
error
(
'x13:regression: This is a bug! Please contact the authors.'
)
end
\ No newline at end of file
end
%@test:1
%$ try
%$ per = dates(52,1996,1);
%$ fid = fopen('test.spc', 'w');
%$ printstart(fid,per);
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
src/utilities/x13/setdefaultmember.m
View file @
ef59f538
function
s
=
setdefaultmember
(
name
)
function
s
=
setdefaultmember
(
name
)
% --*-- Unitary tests --*--
% Sets members of X13 object to default values (empty).
...
...
@@ -82,3 +82,14 @@ switch name
otherwise
error
(
'x13:setdefaultmember: Unknown member!'
)
end
%@test:1
%$ try
%$ setdefaultmember('PyotrIlychTchaikowsky');
%$ t(1) = false;
%$ catch
%$ t(1) = true;
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment