|
11 | 11 | funcs = {};
|
12 | 12 | funcs{end+1} = @test_attrs;
|
13 | 13 | funcs{end+1} = @test_add_data_array;
|
| 14 | + funcs{end+1} = @test_add_data_arrays; |
14 | 15 | funcs{end+1} = @test_get_data_array;
|
15 | 16 | funcs{end+1} = @test_remove_data_array;
|
16 | 17 | funcs{end+1} = @test_update_linked_data_array;
|
17 | 18 | funcs{end+1} = @test_data_array_count;
|
18 | 19 | funcs{end+1} = @test_add_tag;
|
| 20 | + funcs{end+1} = @test_add_tags; |
19 | 21 | funcs{end+1} = @test_has_tag;
|
20 | 22 | funcs{end+1} = @test_get_tag;
|
21 | 23 | funcs{end+1} = @test_remove_tag;
|
22 | 24 | funcs{end+1} = @test_tag_count;
|
23 | 25 | funcs{end+1} = @test_add_multi_tag;
|
| 26 | + funcs{end+1} = @test_add_multi_tags; |
24 | 27 | funcs{end+1} = @test_has_multi_tag;
|
25 | 28 | funcs{end+1} = @test_get_multi_tag;
|
26 | 29 | funcs{end+1} = @test_remove_multi_tag;
|
27 | 30 | funcs{end+1} = @test_multi_tag_count;
|
28 | 31 | funcs{end+1} = @test_add_source;
|
| 32 | + funcs{end+1} = @test_add_sources; |
29 | 33 | funcs{end+1} = @test_remove_source;
|
30 | 34 | funcs{end+1} = @test_has_source;
|
31 | 35 | funcs{end+1} = @test_fetch_sources;
|
|
93 | 97 | assert(strcmp(f.blocks{1}.groups{1}.dataArrays{1}.name, daName));
|
94 | 98 | end
|
95 | 99 |
|
| 100 | +%% Test: Add dataArrays by entity cell array |
| 101 | +function [] = test_add_data_arrays ( varargin ) |
| 102 | + testFile = fullfile(pwd, 'tests', 'testRW.h5'); |
| 103 | + f = nix.File(testFile, nix.FileMode.Overwrite); |
| 104 | + b = f.create_block('testBlock', 'nixBlock'); |
| 105 | + g = b.create_group('testGroup', 'nixGroup'); |
| 106 | + tmp = b.create_data_array('testDataArray1', 'nixDataArray', nix.DataType.Double, [2 3]); |
| 107 | + tmp = b.create_data_array('testDataArray2', 'nixDataArray', nix.DataType.Double, [2 3]); |
| 108 | + tmp = b.create_data_array('testDataArray3', 'nixDataArray', nix.DataType.Double, [2 3]); |
| 109 | + |
| 110 | + assert(isempty(g.dataArrays)); |
| 111 | + |
| 112 | + try |
| 113 | + g.add_data_arrays('hurra'); |
| 114 | + catch ME |
| 115 | + assert(strcmp(ME.message, 'Expected cell array')); |
| 116 | + end; |
| 117 | + assert(isempty(g.dataArrays)); |
| 118 | + |
| 119 | + try |
| 120 | + g.add_data_arrays({12, 13}); |
| 121 | + catch ME |
| 122 | + assert(~isempty(strfind(ME.message, 'not a nix.DataArray'))); |
| 123 | + end; |
| 124 | + assert(isempty(g.dataArrays)); |
| 125 | + |
| 126 | + g.add_data_arrays(b.dataArrays()); |
| 127 | + assert(size(g.dataArrays, 1) == 3); |
| 128 | + |
| 129 | + clear g tmp b f; |
| 130 | + f = nix.File(testFile, nix.FileMode.ReadOnly); |
| 131 | + assert(size(f.blocks{1}.groups{1}.dataArrays, 1) == 3); |
| 132 | +end |
| 133 | + |
96 | 134 | %% Test: Get nix.DataArray by id or name
|
97 | 135 | function [] = test_get_data_array( varargin )
|
98 | 136 | fileName = 'testRW.h5';
|
|
236 | 274 | assert(strcmp(f.blocks{1}.groups{1}.tags{2}.name, tagName2));
|
237 | 275 | end
|
238 | 276 |
|
| 277 | +%% Test: Add tags by entity cell array |
| 278 | +function [] = test_add_tags ( varargin ) |
| 279 | + testFile = fullfile(pwd, 'tests', 'testRW.h5'); |
| 280 | + f = nix.File(testFile, nix.FileMode.Overwrite); |
| 281 | + b = f.create_block('testBlock', 'nixBlock'); |
| 282 | + g = b.create_group('testGroup', 'nixGroup'); |
| 283 | + tmp = b.create_tag('testTag1', 'nixTag', [1.0 1.2]); |
| 284 | + tmp = b.create_tag('testTag2', 'nixTag', [1.0 1.2]); |
| 285 | + tmp = b.create_tag('testTag3', 'nixTag', [1.0 1.2]); |
| 286 | + |
| 287 | + assert(isempty(g.tags)); |
| 288 | + |
| 289 | + try |
| 290 | + g.add_tags('hurra'); |
| 291 | + catch ME |
| 292 | + assert(strcmp(ME.message, 'Expected cell array')); |
| 293 | + end; |
| 294 | + assert(isempty(g.tags)); |
| 295 | + |
| 296 | + try |
| 297 | + g.add_tags({12, 13}); |
| 298 | + catch ME |
| 299 | + assert(~isempty(strfind(ME.message, 'not a nix.Tag'))); |
| 300 | + end; |
| 301 | + assert(isempty(g.tags)); |
| 302 | + |
| 303 | + g.add_tags(b.tags()); |
| 304 | + assert(size(g.tags, 1) == 3); |
| 305 | + |
| 306 | + clear g tmp b f; |
| 307 | + f = nix.File(testFile, nix.FileMode.ReadOnly); |
| 308 | + assert(size(f.blocks{1}.groups{1}.tags, 1) == 3); |
| 309 | +end |
| 310 | + |
239 | 311 | %% Test: has nix.Tag by id or name
|
240 | 312 | function [] = test_has_tag( varargin )
|
241 | 313 | fileName = 'testRW.h5';
|
|
363 | 435 | assert(strcmp(f.blocks{1}.groups{1}.multiTags{2}.name, tagName2));
|
364 | 436 | end
|
365 | 437 |
|
| 438 | +%% Test: Add multiTags by entity cell array |
| 439 | +function [] = test_add_multi_tags ( varargin ) |
| 440 | + testFile = fullfile(pwd, 'tests', 'testRW.h5'); |
| 441 | + f = nix.File(testFile, nix.FileMode.Overwrite); |
| 442 | + b = f.create_block('testBlock', 'nixBlock'); |
| 443 | + g = b.create_group('testGroup', 'nixGroup'); |
| 444 | + tmp = b.create_data_array(... |
| 445 | + 'testDataArray', 'nixDataArray', nix.DataType.Double, [1 2]); |
| 446 | + tmp = b.create_multi_tag('testMultiTag1', 'nixMultiTag', b.dataArrays{1}); |
| 447 | + tmp = b.create_multi_tag('testMultiTag2', 'nixMultiTag', b.dataArrays{1}); |
| 448 | + tmp = b.create_multi_tag('testMultiTag3', 'nixMultiTag', b.dataArrays{1}); |
| 449 | + |
| 450 | + assert(isempty(g.multiTags)); |
| 451 | + |
| 452 | + try |
| 453 | + g.add_multi_tags('hurra'); |
| 454 | + catch ME |
| 455 | + assert(strcmp(ME.message, 'Expected cell array')); |
| 456 | + end; |
| 457 | + assert(isempty(g.multiTags)); |
| 458 | + |
| 459 | + try |
| 460 | + g.add_multi_tags({12, 13}); |
| 461 | + catch ME |
| 462 | + assert(~isempty(strfind(ME.message, 'not a nix.MultiTag'))); |
| 463 | + end; |
| 464 | + assert(isempty(g.multiTags)); |
| 465 | + |
| 466 | + g.add_multi_tags(b.multiTags()); |
| 467 | + assert(size(g.multiTags, 1) == 3); |
| 468 | + |
| 469 | + clear g tmp b f; |
| 470 | + f = nix.File(testFile, nix.FileMode.ReadOnly); |
| 471 | + assert(size(f.blocks{1}.groups{1}.multiTags, 1) == 3); |
| 472 | +end |
| 473 | + |
366 | 474 | %% Test: has nix.MultiTag by id or name
|
367 | 475 | function [] = test_has_multi_tag( varargin )
|
368 | 476 | fileName = 'testRW.h5';
|
|
500 | 608 | assert(size(f.blocks{1}.groups{1}.sources, 1) == 2);
|
501 | 609 | end
|
502 | 610 |
|
| 611 | +%% Test: Add sources by entity cell array |
| 612 | +function [] = test_add_sources ( varargin ) |
| 613 | + testFile = fullfile(pwd, 'tests', 'testRW.h5'); |
| 614 | + f = nix.File(testFile, nix.FileMode.Overwrite); |
| 615 | + b = f.create_block('testBlock', 'nixBlock'); |
| 616 | + g = b.create_group('sourceTest', 'nixGroup'); |
| 617 | + tmp = b.create_source('testSource1', 'nixSource'); |
| 618 | + tmp = b.create_source('testSource2', 'nixSource'); |
| 619 | + tmp = b.create_source('testSource3', 'nixSource'); |
| 620 | + |
| 621 | + assert(isempty(g.sources)); |
| 622 | + |
| 623 | + try |
| 624 | + g.add_sources('hurra'); |
| 625 | + catch ME |
| 626 | + assert(strcmp(ME.message, 'Expected cell array')); |
| 627 | + end; |
| 628 | + assert(isempty(g.sources)); |
| 629 | + |
| 630 | + try |
| 631 | + g.add_sources({12, 13}); |
| 632 | + catch ME |
| 633 | + assert(~isempty(strfind(ME.message, 'not a nix.Source'))); |
| 634 | + end; |
| 635 | + assert(isempty(g.sources)); |
| 636 | + |
| 637 | + g.add_sources(b.sources()); |
| 638 | + assert(size(g.sources, 1) == 3); |
| 639 | + |
| 640 | + clear g tmp b f; |
| 641 | + f = nix.File(testFile, nix.FileMode.ReadOnly); |
| 642 | + assert(size(f.blocks{1}.groups{1}.sources, 1) == 3); |
| 643 | +end |
| 644 | + |
503 | 645 | %% Test: Remove sources by entity and id
|
504 | 646 | function [] = test_remove_source ( varargin )
|
505 | 647 | test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
|
|
0 commit comments