diff --git a/src/@dseries/mdiff.m b/src/@dseries/mdiff.m new file mode 100644 index 0000000000000000000000000000000000000000..0924fbcf72741e7a8c9163d91c74703c839f0e0c --- /dev/null +++ b/src/@dseries/mdiff.m @@ -0,0 +1,49 @@ +function o = mdiff(o) % --*-- Unitary tests --*-- + +% Computes monthly differences. +% +% INPUTS +% - o [dseries] +% +% OUTPUTS +% - o [dseries] + +% Copyright (C) 2017 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +o = copy(o); +o.mdiff_(); + +%@test:1 +%$ try +%$ data = transpose(0:1:50); +%$ ts = dseries(data,'1950M1'); +%$ ds = ts.mdiff(); +%$ t(1) = 1; +%$ catch +%$ t(1) = 0; +%$ end +%$ +%$ if t(1) +%$ DATA = NaN(1,ds.vobs); +%$ DATA = [DATA; ones(ds.nobs-1,ds.vobs)]; +%$ t(2) = dassert(ds.data, DATA, 1e-15); +%$ t(3) = dassert(ts.data, data, 1e-15); +%$ end +%$ +%$ T = all(t); +%@eof:1 \ No newline at end of file diff --git a/src/@dseries/mdiff_.m b/src/@dseries/mdiff_.m new file mode 100644 index 0000000000000000000000000000000000000000..73b8a29699caa0d91cedcc4bba645257e28a248d --- /dev/null +++ b/src/@dseries/mdiff_.m @@ -0,0 +1,78 @@ +function o = mdiff_(o) % --*-- Unitary tests --*-- + +% Computes monthly differences. +% +% INPUTS +% - o [dseries] +% +% OUTPUTS +% - o [dseries] + +% Copyright (C) 2017 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch frequency(o) + case 1 + error('dseries::mdiff: I cannot compute monthly differences from yearly data!') + case 4 + error('dseries::mdiff: I cannot compute monthly differences from quarterly data!') + case 12 + o.data(2:end,:) = o.data(2:end,:)-o.data(1:end-1,:); + o.data(1,:) = NaN; + otherwise + error(['dseries::mdiff: object ' inputname(1) ' has unknown frequency']); +end + +for i = 1:vobs(o) + if isempty(o.ops{i}) + o.ops(i) = {['mdiff(' o.name{i} ')']}; + else + o.ops(i) = {['mdiff(' o.ops{i} ')']}; + end +end + +%@test:1 +%$ try +%$ data = transpose(0:1:50); +%$ ts = dseries(data, '1950Q1'); +%$ ts.mdiff_; +%$ t(1) = 0; +%$ catch +%$ t(1) = 1; +%$ end +%$ +%$ T = all(t); +%@eof:1 + +%@test:2 +%$ try +%$ data = transpose(0:1:80); +%$ ts = dseries(data, '1950M1'); +%$ ts.mdiff_; +%$ t(1) = 1; +%$ catch +%$ t(1) = 0; +%$ end +%$ +%$ if t(1) +%$ DATA = NaN(1, ts.vobs); +%$ DATA = [DATA; ones(ts.nobs-1, ts.vobs)]; +%$ t(2) = dassert(ts.data, DATA, 1e-15); +%$ end +%$ +%$ T = all(t); +%@eof:2 diff --git a/src/@dseries/mgrowth.m b/src/@dseries/mgrowth.m new file mode 100644 index 0000000000000000000000000000000000000000..8bf43f41ac69485314a5e8c1926b2e0e0749dc11 --- /dev/null +++ b/src/@dseries/mgrowth.m @@ -0,0 +1,49 @@ +function o = mgrowth(o) % --*-- Unitary tests --*-- + +% Computes monthly growth rates. +% +% INPUTS +% - o [dseries] +% +% OUTPUTS +% - o [dseries] + +% Copyright (C) 2017 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +o = copy(o); +o.mgrowth_(); + +%@test:1 +%$ try +%$ data = (1+.01).^transpose(0:1:50); +%$ ts = dseries(data,'1950M1'); +%$ ds = ts.mgrowth(); +%$ t(1) = 1; +%$ catch +%$ t(1) = 0; +%$ end +%$ +%$ if t(1) +%$ DATA = NaN(1,ds.vobs); +%$ DATA = [DATA; .01*ones(ds.nobs-1,ds.vobs)]; +%$ t(2) = dassert(ds.data,DATA,1e-15); +%$ t(3) = dassert(ts.data,data,1e-15); +%$ end +%$ +%$ T = all(t); +%@eof:1 \ No newline at end of file diff --git a/src/@dseries/mgrowth_.m b/src/@dseries/mgrowth_.m new file mode 100644 index 0000000000000000000000000000000000000000..94c8c2e5595ff69861bee121156811304e2e4270 --- /dev/null +++ b/src/@dseries/mgrowth_.m @@ -0,0 +1,78 @@ +function o = mgrowth_(o) % --*-- Unitary tests --*-- + +% Computes monthly growth rates. +% +% INPUTS +% - o [dseries] +% +% OUTPUTS +% - o [dseries] + +% Copyright (C) 2017 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +switch frequency(o) + case 1 + error('dseries::mgrowth: I cannot compute monthly growth rates from yearly data!') + case 4 + error('dseries::mgrowth: I cannot compute monthly growth rates from quaterly data!') + case 12 + o.data(2:end,:) = o.data(2:end,:)./o.data(1:end-1,:) - 1; + o.data(1,:) = NaN; + otherwise + error(['dseries::mgrowth: object ' inputname(1) ' has unknown frequency']); +end + +for i = 1:vobs(o) + if isempty(o.ops{i}) + o.ops(i) = {['mgrowth(' o.name{i} ')']}; + else + o.ops(i) = {['mgrowth(' o.ops{i} ')']}; + end +end + +%@test:1 +%$ try +%$ data = (1+.01).^transpose(0:1:50); +%$ ts = dseries(data,'1950Q1'); +%$ ts.mgrowth_; +%$ t(1) = 0; +%$ catch +%$ t(1) = 1; +%$ end +%$ +%$ T = all(t); +%@eof:1 + +%@test:2 +%$ try +%$ data = (1+.01).^transpose(0:1:80); +%$ ts = dseries(data, '1950M1'); +%$ ts.mgrowth_; +%$ t(1) = 1; +%$ catch +%$ t(1) = 0; +%$ end +%$ +%$ if t(1) +%$ DATA = NaN(1,ts.vobs); +%$ DATA = [DATA; (1.01-1)*ones(ts.nobs-1, ts.vobs)]; +%$ t(2) = dassert(ts.data, DATA, 1e-15); +%$ end +%$ +%$ T = all(t); +%@eof:2 diff --git a/src/@dseries/struct.m b/src/@dseries/struct.m new file mode 100644 index 0000000000000000000000000000000000000000..dfe0cf58776784fa14982d441c04c0a0382ef6a7 --- /dev/null +++ b/src/@dseries/struct.m @@ -0,0 +1,27 @@ +function p = struct(o) + +% Converts dseries object to structure. + +% Copyright (C) 2017 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. + +warning('off', 'MATLAB:structOnObject'); + +p = struct(o); +p.dates = struct(p.dates); + +warning('on', 'MATLAB:structOnObject'); \ No newline at end of file diff --git a/src/@dseries/subsref.m b/src/@dseries/subsref.m index 23ee9f4f10c02e8383b1e22103f1dd2db17850e9..08c496f1dd4eb97687a1bd380876eff1cb3f2f18 100644 --- a/src/@dseries/subsref.m +++ b/src/@dseries/subsref.m @@ -130,9 +130,11 @@ switch S(1).type 'exp','exp_', ... 'ygrowth','ygrowth_', ... 'qgrowth','qgrowth_', ... + 'mgrowth','mgrowth_', ... 'ydiff','ydiff_', ... 'qdiff','qdiff_', ... 'diff', 'diff_', ... + 'mdiff','mdiff_', ... 'abs','abs_', ... 'isnan', ... 'firstdate', ... diff --git a/src/@x13/clean.m b/src/@x13/clean.m index 9d87ad979d9ce1422fba48be2750bbd7452c5a9e..fc8ce6118c4e46947e9a416541d4f3a23ef6670f 100644 --- a/src/@x13/clean.m +++ b/src/@x13/clean.m @@ -1,4 +1,4 @@ -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 diff --git a/src/@x13/print.m b/src/@x13/print.m index fa8952b83b7dcaa54cc625c0b10eee62d0bf43fe..b9d13c51779b4bac464919a1ca595db1c36a49ee 100644 --- a/src/@x13/print.m +++ b/src/@x13/print.m @@ -1,4 +1,4 @@ -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 unkonwn', conditionningvariables{i}) + error('x13:x11regression: Variable %s is unknown', 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 diff --git a/src/@x13/run.m b/src/@x13/run.m index 2acb8018ad3935eb8c4f0d2657a6908bc84eb21b..73faa7a2d0ddde93cc36af0e6ebe645c782d9b7a 100644 --- a/src/@x13/run.m +++ b/src/@x13/run.m @@ -65,10 +65,18 @@ if ~all(cellfun(@isempty, struct2cell(o.forecast))) for i=1:length(savedoutput) if exist(sprintf('%s.%s', basename, lower(savedoutput{i}))) tmp = importdata(sprintf('%s.%s', basename, lower(savedoutput{i}))); + initdate = num2str(tmp.data(1,1)); % wrong in series + t = o.y.dates; name = strsplit(tmp.textdata{1},'\t'); name = name(2:end); data = tmp.data(:,2:end); - o.results.(savedoutput{i}) = dseries(data, lastobservedperiod(o.y)+1, name); + if isempty(data) + disp(['x13:forecast:: Problem reading ' sprintf('%s.%s', basename, lower(savedoutput{i})) '. Output formatting may be incorrect!']); + initdate = tmp.textdata{3,1}; + o.results.(savedoutput{i}) = dseries(NaN(length(tmp.data),numel(name)), dates(t.freq,str2num(initdate(1:4)),str2num(initdate(5:end))),name); + else + o.results.(savedoutput{i}) = dseries(data, dates(t.freq,str2num(initdate(1:4)),str2num(initdate(5:end))),name); + end end end end diff --git a/src/@x13/subsasgn.m b/src/@x13/subsasgn.m index 3fe9956ed303eba330cdd6a81fc9e9b25eeb3f08..163c2dd33b3c806905a4026186e364773922532d 100644 --- a/src/@x13/subsasgn.m +++ b/src/@x13/subsasgn.m @@ -1,4 +1,4 @@ -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 diff --git a/src/@x13/subsref.m b/src/@x13/subsref.m index df687ff1b06b5bfa7f8c5231e028de1827a79c88..80466b1c8e223bf7ef051bbccd5afec424367866 100644 --- a/src/@x13/subsref.m +++ b/src/@x13/subsref.m @@ -1,4 +1,4 @@ -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 diff --git a/src/@x13/x13.m b/src/@x13/x13.m index 98fc4422ebd83534532b3a85937cf25c554414b1..fe169c42500fdafbcdfe7a2216ae9dfe2d5dfab4 100644 --- a/src/@x13/x13.m +++ b/src/@x13/x13.m @@ -1,4 +1,4 @@ -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 diff --git a/src/utilities/x13/checkcommandcompatibility.m b/src/utilities/x13/checkcommandcompatibility.m index 9359cddc821821ecb8e686c7c7f6261c8b53d183..a710383a8cce10f3e81ad51214cf0ca3dc7e7d77 100644 --- a/src/utilities/x13/checkcommandcompatibility.m +++ b/src/utilities/x13/checkcommandcompatibility.m @@ -1,4 +1,4 @@ -function checkcommandcompatibility(o, comm) +function checkcommandcompatibility(o, comm) % --*-- Unitary tests --*-- % Checks for compatibility of X13 commands. @@ -20,7 +20,7 @@ function checkcommandcompatibility(o, comm) switch comm case 'arima' if ismember('automdl', o.commands) - error('x13:arima: ARIMA command is not compatible with AUTOMDL command!') + error('x13:arima: ARIMA command is not compatible with AUTOMDL command!') elseif ismember('pickmdl', o.commands) error('x13:arima: ARIMA command is not compatible with PICKMDL command!') end @@ -34,7 +34,31 @@ switch comm if ismember('arima', o.commands) error('x13:pickmdl: PICKMDL command is not compatible with ARIMA command!') elseif ismember('automdl', o.commands) - error('x13:pickmdl: PICKMDL command is not compatible with AUTOMDL command!') - end + 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 diff --git a/src/utilities/x13/checkoptioncompatibility.m b/src/utilities/x13/checkoptioncompatibility.m index e405ae2ca26818c869db737c1a60dfa406e2ddb5..541ccdaa236b64b6a36c593dbc5633aa70075e64 100644 --- a/src/utilities/x13/checkoptioncompatibility.m +++ b/src/utilities/x13/checkoptioncompatibility.m @@ -1,4 +1,4 @@ -function checkoptioncompatibility(o) +function checkoptioncompatibility(o) % --*-- Unitary tests --*-- % Checks for compatibility of options in different X13 commands. @@ -34,5 +34,36 @@ if ~isempty(o.estimate.file) error('Command AUTOMDL not compatible with ESTIMATE.file option!'); elseif ismember('pickmdl',o.commands) error('Command PICKMDL not compatible with ESTIMATE.file option!'); - end -end \ No newline at end of file + end +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 diff --git a/src/utilities/x13/isoption.m b/src/utilities/x13/isoption.m index e63d44ae121bdd20b4113283b10ae1a0bbf7ef53..6c3bef5a542d19ef5ad27abb39b91ab732bdab11 100644 --- a/src/utilities/x13/isoption.m +++ b/src/utilities/x13/isoption.m @@ -1,4 +1,4 @@ -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 = [b;c]; +%$ T = all(t); +%@eof:2 \ No newline at end of file diff --git a/src/utilities/x13/printoption.m b/src/utilities/x13/printoption.m index 4e65e0db75a12f058bf33d0f26e23e2f79e835df..d33cfbe19cd906d81f70336ccfd439fefa3c1f8b 100644 --- a/src/utilities/x13/printoption.m +++ b/src/utilities/x13/printoption.m @@ -1,4 +1,4 @@ -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 diff --git a/src/utilities/x13/printspan.m b/src/utilities/x13/printspan.m index aceef2754413b28bafbc29e9dfce31f647fb3624..fe1ba46e088a48a7e12ab575f962f856b4f16ef6 100644 --- a/src/utilities/x13/printspan.m +++ b/src/utilities/x13/printspan.m @@ -1,4 +1,4 @@ -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 diff --git a/src/utilities/x13/printstart.m b/src/utilities/x13/printstart.m index 43bfea56fc54fc78c333934f88bc0c77ae416aea..1d803e5be61d73e1c291561cf7e6cc87c04461c2 100644 --- a/src/utilities/x13/printstart.m +++ b/src/utilities/x13/printstart.m @@ -1,4 +1,4 @@ -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 diff --git a/src/utilities/x13/setdefaultmember.m b/src/utilities/x13/setdefaultmember.m index a266a0f698582c5787c4d440a9272a434d1db08d..356480bc538c7833409635a05e7581938260fa96 100644 --- a/src/utilities/x13/setdefaultmember.m +++ b/src/utilities/x13/setdefaultmember.m @@ -1,4 +1,4 @@ -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