|
26 | 26 | funcs{end+1} = @test_set_metadata;
|
27 | 27 | funcs{end+1} = @test_open_metadata;
|
28 | 28 | funcs{end+1} = @test_create_group;
|
29 |
| - funcs{end+1} = @test_delete_group; |
30 | 29 | funcs{end+1} = @test_has_group;
|
| 30 | + funcs{end+1} = @test_get_group; |
| 31 | + funcs{end+1} = @test_delete_group; |
31 | 32 | end
|
32 | 33 |
|
33 | 34 | function [] = test_attrs( varargin )
|
|
375 | 376 | assert(strcmp(b.open_metadata.name, 'testSection'));
|
376 | 377 | end
|
377 | 378 |
|
378 |
| -%% Test: Create Group |
| 379 | +%% Test: Create nix.Group |
379 | 380 | function [] = test_create_group( varargin )
|
380 | 381 | fileName = 'testRW.h5';
|
381 | 382 | groupName = 'testGroup';
|
|
397 | 398 | assert(strcmp(f.blocks{1}.groups{1}.name, groupName));
|
398 | 399 | end
|
399 | 400 |
|
400 |
| -%% Test: delete group by entity and id |
| 401 | +%% Test: nix.Block has nix.Group by name or id |
| 402 | +function [] = test_has_group( varargin ) |
| 403 | + groupName = 'testGroup'; |
| 404 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 405 | + b = f.createBlock('grouptest', 'nixBlock'); |
| 406 | + |
| 407 | + assert(~b.has_group('I do not exist')); |
| 408 | + |
| 409 | + g = b.create_group(groupName, 'nixGroup'); |
| 410 | + assert(b.has_group(b.groups{1}.id)); |
| 411 | + assert(b.has_group(groupName)); |
| 412 | + |
| 413 | + b.delete_group(b.groups{1}); |
| 414 | + assert(~b.has_group(g.id)); |
| 415 | +end |
| 416 | + |
| 417 | +%% Test: Get nix.Group by name or id |
| 418 | +function [] = test_get_group( varargin ) |
| 419 | + groupName = 'testGroup'; |
| 420 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
| 421 | + b = f.createBlock('grouptest', 'nixBlock'); |
| 422 | + g = b.create_group(groupName, 'nixGroup'); |
| 423 | + gID = g.id; |
| 424 | + |
| 425 | + clear g b f; |
| 426 | + f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.ReadOnly); |
| 427 | + assert(strcmp(f.blocks{1}.get_group(gID).name, groupName)); |
| 428 | + assert(strcmp(f.blocks{1}.get_group(groupName).name, groupName)); |
| 429 | +end |
| 430 | + |
| 431 | +%% Test: Delete nix.Group by entity and id |
401 | 432 | function [] = test_delete_group( varargin )
|
402 | 433 | fileName = 'testRW.h5';
|
403 | 434 | groupType = 'nixGroup';
|
|
419 | 450 | f = nix.File(fullfile(pwd, 'tests', fileName), nix.FileMode.ReadOnly);
|
420 | 451 | assert(isempty(f.blocks{1}.groups));
|
421 | 452 | end
|
422 |
| - |
423 |
| -%% Test: Block has Group by name or id |
424 |
| -function [] = test_has_group( varargin ) |
425 |
| - groupName = 'testGroup'; |
426 |
| - f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite); |
427 |
| - b = f.createBlock('grouptest', 'nixBlock'); |
428 |
| - |
429 |
| - assert(~b.has_group('I do not exist')); |
430 |
| - |
431 |
| - g = b.create_group(groupName, 'nixGroup'); |
432 |
| - assert(b.has_group(b.groups{1}.id)); |
433 |
| - assert(b.has_group(groupName)); |
434 |
| - |
435 |
| - b.delete_group(b.groups{1}); |
436 |
| - assert(~b.has_group(g.id)); |
437 |
| -end |
|
0 commit comments