25
25
funcs{end + 1 } = @test_has_tag ;
26
26
funcs{end + 1 } = @test_set_metadata ;
27
27
funcs{end + 1 } = @test_open_metadata ;
28
+ funcs{end + 1 } = @test_create_group ;
29
+ funcs{end + 1 } = @test_delete_group ;
30
+ funcs{end + 1 } = @test_has_group ;
28
31
end
29
32
30
33
function [] = test_attrs( varargin )
371
374
372
375
assert(strcmp(b .open_metadata .name , ' testSection' ));
373
376
end
377
+
378
+ %% Test: Create Group
379
+ function [] = test_create_group( varargin )
380
+ fileName = ' testRW.h5' ;
381
+ groupName = ' testGroup' ;
382
+ groupType = ' nixGroup' ;
383
+
384
+ f = nix .File(fullfile(pwd , ' tests' , fileName ), nix .FileMode .Overwrite );
385
+ b = f .createBlock(' grouptest' , ' nixBlock' );
386
+
387
+ assert(isempty(b .groups ));
388
+
389
+ g = b .create_group(groupName , groupType );
390
+ assert(strcmp(g .name , groupName ));
391
+ assert(strcmp(g .type , groupType ));
392
+ assert(~isempty(b .groups ));
393
+
394
+ clear g b f ;
395
+ f = nix .File(fullfile(pwd , ' tests' , fileName ), nix .FileMode .ReadOnly );
396
+ assert(~isempty(f.blocks{1 }.groups));
397
+ assert(strcmp(f.blocks{1 }.groups{1 }.name, groupName ));
398
+ end
399
+
400
+ %% Test: delete group by entity and id
401
+ function [] = test_delete_group( varargin )
402
+ fileName = ' testRW.h5' ;
403
+ groupType = ' nixGroup' ;
404
+
405
+ f = nix .File(fullfile(pwd , ' tests' , fileName ), nix .FileMode .Overwrite );
406
+ b = f .createBlock(' grouptest' , ' nixBlock' );
407
+ g1 = b .create_group(' testGroup1' , groupType );
408
+ g2 = b .create_group(' testGroup2' , groupType );
409
+
410
+ assert(size(b .groups , 1 ) == 2 );
411
+ assert(b .delete_group(b.groups{2 }.id));
412
+ assert(size(b .groups , 1 ) == 1 );
413
+ assert(b .delete_group(b.groups{1 }));
414
+ assert(isempty(b .groups ));
415
+
416
+ assert(~b .delete_group(' I do not exist' ));
417
+
418
+ clear g b f ;
419
+ f = nix .File(fullfile(pwd , ' tests' , fileName ), nix .FileMode .ReadOnly );
420
+ assert(isempty(f.blocks{1 }.groups));
421
+ end
422
+
423
+ %% Test: Block has Group by entity
424
+ function [] = test_has_group( varargin )
425
+ %{
426
+ f = nix.File(fullfile(pwd, 'tests', 'testRW.h5', nix.FileMode.Overwrite));
427
+ b = f.createBlock('grouptest', 'nixBlock');
428
+
429
+ g = b.create_group('testGroup', 'nixGroup');
430
+ assert(b.has_group(b.groups{1}));
431
+
432
+ b.delete_group(b.groups{1});
433
+ assert(~b.has_group(g));
434
+ %}
435
+ disp(' Test Block.has_group ... TODO (function not working at the moment)' );
436
+ end
0 commit comments