|
16 | 16 | funcs{end+1} = @test_values;
|
17 | 17 | funcs{end+1} = @test_value_count;
|
18 | 18 | funcs{end+1} = @test_values_delete;
|
| 19 | + funcs{end+1} = @test_property_compare; |
19 | 20 | end
|
20 | 21 |
|
21 | 22 | %% Test: Access Attributes
|
|
145 | 146 | f = nix.File(testFile, nix.FileMode.ReadOnly);
|
146 | 147 | assert(isempty(f.sections{1}.allProperties{1}.values));
|
147 | 148 | end
|
| 149 | + |
| 150 | +%% Test: Compare properties |
| 151 | +function [] = test_property_compare( varargin ) |
| 152 | + testFile = fullfile(pwd,'tests','testRW.h5'); |
| 153 | + f = nix.File(testFile, nix.FileMode.Overwrite); |
| 154 | + s1 = f.create_section('testSection1', 'nixSection'); |
| 155 | + s2 = f.create_section('testSection2', 'nixSection'); |
| 156 | + |
| 157 | + p = s1.create_property_with_value('property', {true, false, true}); |
| 158 | + |
| 159 | + % test invalid property comparison |
| 160 | + try |
| 161 | + p.compare('I shall crash and burn'); |
| 162 | + catch ME |
| 163 | + assert(strcmp(ME.message, 'Function only supports comparison of Properties.')); |
| 164 | + end |
| 165 | + |
| 166 | + % test property equal comparison |
| 167 | + assert(~p.compare(p)); |
| 168 | + |
| 169 | + % test property not eqal |
| 170 | + pNEq = s2.create_property_with_value('property', {true, false}); |
| 171 | + assert(p.compare(pNEq)~=0); |
| 172 | +end |
0 commit comments