|
23 | 23 | funcs{end+1} = @test_open_source;
|
24 | 24 | funcs{end+1} = @test_has_multitag;
|
25 | 25 | funcs{end+1} = @test_has_tag;
|
| 26 | + funcs{end+1} = @test_set_metadata; |
26 | 27 | funcs{end+1} = @test_open_metadata;
|
27 | 28 | end
|
28 | 29 |
|
|
345 | 346 | assert(~b.has_tag('I do not exist'));
|
346 | 347 | end
|
347 | 348 |
|
| 349 | +%% Test: Set metadata |
| 350 | +function [] = test_set_metadata ( varargin ) |
| 351 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 352 | + tmp = f.createSection('testSection1', 'nixSection'); |
| 353 | + tmp = f.createSection('testSection2', 'nixSection'); |
| 354 | + b = f.createBlock('testBlock', 'nixBlock'); |
| 355 | + |
| 356 | + assert(isempty(b.open_metadata)); |
| 357 | + b.set_metadata(f.sections{1}); |
| 358 | + assert(strcmp(b.open_metadata.name, 'testSection1')); |
| 359 | + b.set_metadata(f.sections{2}); |
| 360 | + assert(strcmp(b.open_metadata.name, 'testSection2')); |
| 361 | + b.set_metadata(''); |
| 362 | + assert(isempty(b.open_metadata)); |
| 363 | +end |
| 364 | + |
348 | 365 | function [] = test_open_metadata( varargin )
|
349 | 366 | %% Test: Open metadata
|
350 |
| - test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
351 |
| - getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
| 367 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 368 | + tmp = f.createSection('testSection', 'nixSection'); |
| 369 | + b = f.createBlock('testBlock', 'nixBlock'); |
| 370 | + b.set_metadata(f.sections{1}); |
352 | 371 |
|
353 |
| - assert(isempty(getBlock.open_metadata())) |
354 |
| - |
355 |
| - %-- ToDo implement test for exising metadata |
356 |
| - %getBlock = test_file.openBlock(test_file.blocks{1,1}.name); |
357 |
| - %assert(~isempty(getBlock.open_metadata())) |
358 |
| - disp('Test Block: open existing metadata ... TODO (proper testfile)'); |
| 372 | + assert(strcmp(b.open_metadata.name, 'testSection')); |
359 | 373 | end
|
0 commit comments