|
11 | 11 | funcs{end+1} = @test_has_section;
|
12 | 12 | funcs{end+1} = @test_attrs;
|
13 | 13 | funcs{end+1} = @test_properties;
|
14 |
| - funcs{end+1} = @test_create_property_data_type; |
| 14 | + funcs{end+1} = @test_create_property; |
| 15 | + funcs{end+1} = @test_create_property_with_value; |
15 | 16 | funcs{end+1} = @test_delete_property;
|
16 | 17 | funcs{end+1} = @test_open_property;
|
17 | 18 | funcs{end+1} = @test_link;
|
|
139 | 140 | end
|
140 | 141 |
|
141 | 142 | %% Test: Create property by data type
|
142 |
| -function [] = test_create_property_data_type( varargin ) |
| 143 | +function [] = test_create_property( varargin ) |
143 | 144 | f = nix.File(fullfile(pwd,'tests','testRW.h5'), nix.FileMode.Overwrite);
|
144 | 145 | s = f.createSection('mainSection', 'nixSection');
|
145 | 146 |
|
|
153 | 154 | assert(strcmp(s.allProperties{1}.name, 'newProperty1'));
|
154 | 155 | end
|
155 | 156 |
|
| 157 | +%% Test: Create property with value |
| 158 | +function [] = test_create_property_with_value( varargin ) |
| 159 | + f = nix.File(fullfile(pwd,'tests','testRW.h5'), nix.FileMode.Overwrite); |
| 160 | + s = f.createSection('mainSection', 'nixSection'); |
| 161 | + |
| 162 | + tmp = s.create_property_with_value('doubleProperty', {5, 6, 7, 8}); |
| 163 | + assert(strcmp(s.allProperties{1}.name, 'doubleProperty')); |
| 164 | + assert(s.allProperties{1}.values{1} == 5); |
| 165 | + assert(size(s.allProperties{1}.values, 2) == 4); |
| 166 | + assert(strcmpi(tmp.datatype,'double')); |
| 167 | + |
| 168 | + tmp = s.create_property_with_value('stringProperty', {'this', 'has', 'strings'}); |
| 169 | + assert(strcmp(s.allProperties{2}.name, 'stringProperty')); |
| 170 | + assert(strcmp(s.allProperties{2}.values{1}, 'this')); |
| 171 | + assert(size(s.allProperties{2}.values, 2) == 3); |
| 172 | + assert(strcmpi(tmp.datatype, 'string')); |
| 173 | + |
| 174 | + tmp = s.create_property_with_value('booleanProperty', {true, false, true}); |
| 175 | + assert(strcmp(s.allProperties{3}.name, 'booleanProperty')); |
| 176 | + assert(s.allProperties{3}.values{1}); |
| 177 | + assert(~s.allProperties{3}.values{2}); |
| 178 | + assert(size(s.allProperties{3}.values, 2) == 3); |
| 179 | + assert(strcmpi(tmp.datatype, 'bool')); |
| 180 | +end |
| 181 | + |
156 | 182 | %% Test: Delete property by entity, propertyStruct, ID and name
|
157 | 183 | function [] = test_delete_property( varargin )
|
158 | 184 | f = nix.File(fullfile(pwd,'tests','testRW.h5'), nix.FileMode.Overwrite);
|
|
0 commit comments