1414utf2
1515end
1616
17+ properties (TestParameter )
18+ type = {' single' , ' double' , ' int8' , ' int16' , ' int32' , ' int64' , ...
19+ ' uint8' , ' uint16' , ' uint32' , ' uint64' }
20+ end
21+
1722methods (TestClassSetup )
1823function setup_file(tc )
19- tc .applyFixture(matlab .unittest .fixtures .WorkingFolderFixture())
24+ tc .applyFixture(matlab .unittest .fixtures .WorkingFolderFixture());
2025
2126tc.A0 = 42 .;
2227tc.A1 = [42 .; 43 .];
@@ -28,7 +33,7 @@ function setup_file(tc)
2833tc.utf1 = [tc .utf0 ; " ☎" ];
2934tc.utf2 = [tc .utf0 , " ☎" ; " 📞" , " 👋" ];
3035
31- tc.file = fullfile(pwd(), class(tc ) + " .nc" );
36+ tc.file = fullfile(pwd(), [ class(tc ), ' .nc' ] );
3237
3338% create test data first, so that parallel tests works
3439stdlib .ncsave(tc .file , ' A0' , tc .A0 )
@@ -38,21 +43,20 @@ function setup_file(tc)
3843stdlib .ncsave(tc .file , ' A4' , tc .A4 , " dims" , {' x4' , size(tc .A4 ,1 ), ' y4' , size(tc .A4 ,2 ), ' z4' , size(tc .A4 ,3 ), ' w4' , size(tc .A4 ,4 )})
3944
4045if ~stdlib .matlabOlderThan(' R2021b' )
41- stdlib .ncsave(tc .file , " utf0" , tc .utf0 )
42- stdlib .ncsave(tc .file , " utf1" , tc .utf1 , " dims" , {' s1' , size(tc .utf1 , 1 )})
43- stdlib .ncsave(tc .file , " utf2" , tc .utf2 , " dims" , {' s1' , size(tc .utf2 , 1 ), ' t1' , size(tc .utf2 , 2 )})
46+ stdlib .ncsave(tc .file , ' utf0' , tc .utf0 )
47+ stdlib .ncsave(tc .file , ' utf1' , tc .utf1 , " dims" , {' s1' , size(tc .utf1 , 1 )})
48+ stdlib .ncsave(tc .file , ' utf2' , tc .utf2 , " dims" , {' s1' , size(tc .utf2 , 1 ), ' t1' , size(tc .utf2 , 2 )})
4449end
4550
4651stdlib .ncsave(tc .file , ' /t/x' , 12 )
4752stdlib .ncsave(tc .file , ' /t/y' , 13 )
4853stdlib .ncsave(tc .file , ' /j/a/b' , 6 )
4954
50- tc .assertThat(tc .file , matlab .unittest .constraints .IsFile )
5155end
5256end
5357
5458
55- methods (Test , TestTags = {' R2019b ' })
59+ methods (Test , TestTags = {' R2017b ' })
5660
5761function test_netcdf_version(tc )
5862tc .verifyTrue(stdlib .version_atleast(stdlib .nc_get_version(), " 4.6" ), " version unexpected" )
@@ -68,33 +72,31 @@ function test_get_variables(tc)
6872tc .verifyEqual(sort(stdlib .ncvariables(tc .file )), k )
6973
7074% 1-level group
71- v = stdlib .ncvariables(tc .file , " /t " );
75+ v = stdlib .ncvariables(tc .file , ' /t ' );
7276tc .verifyEqual(sort(v ), [" x" , " y" ])
7377
7478% traversal
75- tc .verifyEmpty(stdlib .ncvariables(tc .file , " /j " ) )
79+ tc .verifyEmpty(stdlib .ncvariables(tc .file , ' /j ' ) )
7680
77- tc .verifyEqual(stdlib .ncvariables(tc .file , " /j/a" ) , " b" )
81+ tc .verifyEqual(stdlib .ncvariables(tc .file , ' /j/a' ) , " b" )
7882end
7983
8084
8185function test_exists(tc )
82- import matlab .unittest .constraints .IsScalar
8386
84- tc .verifyTrue(stdlib .ncexists(tc .file , " A1 " ))
85- tc .verifyFalse(stdlib .ncexists(tc .file , " not-exist" ))
87+ tc .verifyTrue(stdlib .ncexists(tc .file , ' A1 ' ))
88+ tc .verifyFalse(stdlib .ncexists(tc .file , ' not-exist' ))
8689
8790end
8891
8992
9093function test_size(tc )
91- import matlab .unittest .constraints .IsScalar
9294
9395s = stdlib .ncsize(tc .file , ' A0' );
9496tc .verifyEmpty(s )
9597
9698s = stdlib .ncsize(tc .file , ' A1' );
97- tc .verifyThat(s , IsScalar )
99+ tc .verifyThat(s , matlab . unittest . constraints . IsScalar )
98100tc .verifyEqual(s , 2 )
99101
100102s = stdlib .ncsize(tc .file , ' A2' );
@@ -113,11 +115,9 @@ function test_size(tc)
113115
114116
115117function test_read(tc )
116- import matlab .unittest .constraints .IsScalar
117-
118118
119119s = ncread(tc .file , ' A0' );
120- tc .verifyThat(s , IsScalar )
120+ tc .verifyThat(s , matlab . unittest . constraints . IsScalar )
121121tc .verifyEqual(s , 42 )
122122
123123s = ncread(tc .file , ' A1' );
@@ -138,30 +138,23 @@ function test_read(tc)
138138end
139139
140140
141- function test_coerce(tc )
142-
143- for type = [" single" , " double" , ...
144- " int8" , " int16" , " int32" , " int64" , ...
145- " uint8" , " uint16" , " uint32" , " uint64" ]
146-
147- stdlib .ncsave(tc .file , type , 0 , " type" , type )
148-
149- tc .verifyClass(ncread(tc .file , type ), type )
150- end
141+ function test_coerce(tc , type )
142+ stdlib .ncsave(tc .file , type , 0 , " type" , type )
151143
144+ tc .verifyClass(ncread(tc .file , type ), type )
152145end
153146
154147
155148function test_rewrite(tc )
156149tc.A2 = 3 * magic(4 );
157- stdlib .ncsave(tc .file , " A2 " , tc .A2 , " dims" , {' x2' , size(tc .A2 ,1 ), ' y2' , size(tc .A2 ,2 )})
150+ stdlib .ncsave(tc .file , ' A2 ' , tc .A2 , " dims" , {' x2' , size(tc .A2 ,1 ), ' y2' , size(tc .A2 ,2 )})
158151
159152tc .verifyEqual(ncread(tc .file , ' A2' ), 3 * magic(4 ))
160153end
161154
162155
163156function test_real_only(tc )
164- tc .verifyError(@() stdlib .ncsave(tc .file , " bad_imag" , 1j ), ' MATLAB:validators:mustBeReal' )
157+ tc .verifyError(@() stdlib .ncsave(tc .file , ' bad_imag' , 1j ), ' MATLAB:validators:mustBeReal' )
165158end
166159
167160end
0 commit comments