11classdef TestFileImpure < matlab .unittest .TestCase
22
3- properties (ClassSetupParameter )
4- classToTest = {" TestFileImpure" };
5- end
6-
73properties (TestParameter )
84p_exists = {{pwd(), true }, {mfilename(" fullpath" ) + " .m" , true }, {" TestFileImpure.m" , true } {tempname, false }}
95% on CI matlabroot can be writable!
1713{tempname , tempname , false }, ...
1814{" .." , " ./.." , true }, ...
1915{" .." , pwd() + " /.." , true }}
20- end
2116
22- properties
23- tobj
17+ ph = {{0 , ' "stdin"' }, {1 , ' "stdout"' }, {2 , ' "stderr"' }, {fopen(tempname), string.empty}}
2418end
2519
2620
2721methods (TestParameterDefinition , Static )
2822
29- function p_expand = init_expand(classToTest ) % #ok<INUSD>
23+ function p_expand = init_expand()
3024cwd = fileparts(mfilename(" fullpath" ));
3125top = fullfile(cwd , " .." );
3226addpath(top )
@@ -42,14 +36,9 @@ function setup_path(tc)
4236tc .applyFixture(matlab .unittest .fixtures .PathFixture(top ))
4337end
4438
45- function classSetup(tc , classToTest )
46- constructor = str2func(classToTest );
47- tc.tobj = constructor();
48- end
49-
5039end
5140
52- methods (Test , ParameterCombination = ' sequential ' )
41+ methods (Test )
5342
5443function test_exists(tc , p_exists )
5544tc .verifyEqual(stdlib .exists(p_exists{1 }), p_exists{2 })
@@ -106,11 +95,8 @@ function test_get_permissions(tc)
10695tc .verifyThat(p , StartsWithSubstring(" r" ))
10796end
10897
109- function test_handle2filename(tc )
110- tc .verifyEqual(stdlib .handle2filename(0 ), ' "' + " stdin" + ' "' )
111- tc .verifyEqual(stdlib .handle2filename(1 ), ' "' + " stdout" + ' "' )
112- tc .verifyEqual(stdlib .handle2filename(2 ), ' "' + " stderr" + ' "' )
113- tc .verifyEmpty(stdlib .handle2filename(fopen(tempname )))
98+ function test_handle2filename(tc , ph )
99+ tc .verifyEqual(stdlib .handle2filename(ph{1 }), string(ph{2 }))
114100end
115101
116102end
0 commit comments