source: Roms_tools/mexcdf/snctools/tests/test_nc_info.m @ 1

Last change on this file since 1 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 3.1 KB
Line 
1function test_nc_info ( )
2% TEST_NC_INFO:
3%
4% Depends upon nc_add_dimension, nc_addvar
5%
6% 1st set of tests should fail
7% test 1:  no input arguments, should fail
8% test 2:  too many inputs
9% test 3:  1 input, not a netcdf file
10%
11% 2nd set of tests should succeed
12% test 4:  empty netcdf file
13% test 5:  netcdf file has dimensions, but no variables.
14% test 6:  netcdf file has unlimited variables, fixed variables
15%          and fixed variables, and global attributes
16
17%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18%
19% $Id: test_nc_info.m 2426 2007-11-11 03:56:45Z johnevans007 $
20% $LastChangedDate: 2007-11-10 22:56:45 -0500 (Sat, 10 Nov 2007) $
21% $LastChangedRevision: 2426 $
22% $LastChangedBy: johnevans007 $
23%
24%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
26fprintf ( 1, 'NC_INFO:  starting test suite...\n' );
27test_001 ( 'testdata/empty.nc' );
28test_002 ( 'testdata/empty.nc' );
29test_003 ( mfilename );
30test_004 ( 'testdata/empty.nc' );
31test_005 ( 'testdata/just_one_dimension.nc' );
32test_006 ( 'testdata/full.nc' );
33return
34
35
36
37
38
39function test_001 ( ncfile )
40try
41        nc = nc_info;
42        msg = sprintf ( '%s:   succeeded when it should have failed.\n', mfilename  );
43        error ( msg );
44end
45return
46
47
48
49
50
51function test_002 ( ncfile )
52try
53        nc = nc_info ( ncfile, 'blah' );
54        msg = sprintf ( '%s:   succeeded when it should have failed.\n', mfilename  );
55        error ( msg );
56end
57return
58
59
60
61
62
63function test_003 (ncfile)
64try
65        nc = nc_info ( ncfile );
66        error ( 'succeeded when it should have failed.' );
67end
68return
69
70
71
72
73
74
75
76function test_004 ( ncfile )
77
78nc = nc_info ( ncfile );
79if ~strcmp ( nc.Filename, ncfile )
80        msg = sprintf ( '%s:  :  Filename was wrong.\n', mfilename  );
81        error ( msg );
82end
83if ( length ( nc.Dimension ) ~= 0 )
84        msg = sprintf ( '%s:  :  Dimension was wrong.\n', mfilename  );
85        error ( msg );
86end
87if ( length ( nc.Dataset ) ~= 0 )
88        msg = sprintf ( '%s:  :  Dataset was wrong.\n', mfilename  );
89        error ( msg );
90end
91if ( length ( nc.Attribute ) ~= 0 )
92        msg = sprintf ( '%s:  :  Attribute was wrong.\n', mfilename  );
93        error ( msg );
94end
95return
96
97
98
99
100
101
102
103
104
105function test_005 ( ncfile )
106
107nc = nc_info ( ncfile );
108if ~strcmp ( nc.Filename, ncfile )
109        msg = sprintf ( '%s:  :  Filename was wrong.\n', mfilename  );
110        error ( msg );
111end
112if ( length ( nc.Dimension ) ~= 1 )
113        msg = sprintf ( '%s:  :  Dimension was wrong.\n', mfilename  );
114        error ( msg );
115end
116if ( length ( nc.Dataset ) ~= 0 )
117        msg = sprintf ( '%s:  :  Dataset was wrong.\n', mfilename  );
118        error ( msg );
119end
120if ( length ( nc.Attribute ) ~= 0 )
121        msg = sprintf ( '%s:  :  Attribute was wrong.\n', mfilename  );
122        error ( msg );
123end
124return
125
126
127
128
129
130
131
132
133
134
135function test_006 ( ncfile )
136
137
138nc = nc_info ( ncfile );
139if ~strcmp ( nc.Filename, ncfile )
140        msg = sprintf ( '%s:  :  Filename was wrong.\n', mfilename  );
141        error ( msg );
142end
143if ( length ( nc.Dimension ) ~= 5 )
144        msg = sprintf ( '%s:  :  Dimension was wrong.\n', mfilename  );
145        error ( msg );
146end
147if ( length ( nc.Dataset ) ~= 6 )
148        msg = sprintf ( '%s:  :  Dataset was wrong.\n', mfilename  );
149        error ( msg );
150end
151if ( length ( nc.Attribute ) ~= 1 )
152        msg = sprintf ( '%s:  :  Attribute was wrong.\n', mfilename  );
153        error ( msg );
154end
155return
156
157
158
159
160
161
Note: See TracBrowser for help on using the repository browser.