11
11
funcs{end + 1 } = @test_has_section ;
12
12
funcs{end + 1 } = @test_attrs ;
13
13
funcs{end + 1 } = @test_properties ;
14
+ funcs{end + 1 } = @test_link ;
14
15
end
15
16
16
17
%% Test: Create Section
89
90
function [] = test_attrs( varargin )
90
91
%% Test: Access Attributes / Links
91
92
f = nix .File(fullfile(pwd , ' tests' , ' testRW.h5' ), nix .FileMode .Overwrite );
92
- s1 = f .createSection(' foo' , ' bar' );
93
-
94
- assert(strcmp(s1 .name , ' foo' ));
95
- assert(strcmp(s1 .type , ' bar' ));
96
- assert(isempty(s1 .repository ));
97
- assert(isempty(s1 .mapping ));
98
-
99
- s1.repository = ' rep1' ;
100
- s1.mapping = ' map1' ;
101
- assert(strcmp(s1 .repository , ' rep1' ));
102
- assert(strcmp(s1 .mapping , ' map1' ));
103
-
104
- s1.repository = ' ' ;
105
- s1.mapping = ' ' ;
106
- assert(isempty(s1 .repository ));
107
- assert(isempty(s1 .mapping ));
108
-
109
- assert(isempty(s1 .link ));
110
-
111
- % TODO rewrite tests for link / parent
112
-
113
- f = nix .File(fullfile(pwd , ' tests' , ' test.h5' ), nix .FileMode .ReadOnly );
114
- s1 = f.sections{3 };
115
-
116
- assert(strcmp(s1 .name , ' Sessions' ));
117
- assert(strcmp(s1 .type , ' nix.metadata.section' ));
118
- assert(isempty(s1 .repository ));
119
- assert(isempty(s1 .mapping ));
120
-
121
- subj = s1.sections{1 }.sections{1 }.link;
122
- assert(strcmp(subj .name , ' Subject' ));
123
-
124
- emp_ty = s1.sections{1 }.link;
125
- assert(isempty(emp_ty ));
93
+ s = f .createSection(' foo' , ' bar' );
94
+
95
+ assert(~isempty(s .id ));
96
+
97
+ assert(strcmp(s .name , ' foo' ));
98
+ assert(strcmp(s .type , ' bar' ));
99
+ assert(isempty(s .repository ));
100
+ assert(isempty(s .mapping ));
101
+ assert(isempty(s .definition ));
102
+
103
+ s.type = ' nixBlock' ;
104
+ s.definition = ' section definition' ;
105
+ s.repository = ' rep1' ;
106
+ s.mapping = ' map1' ;
107
+ assert(strcmp(s .type , ' nixBlock' ));
108
+ assert(strcmp(s .definition , ' section definition' ));
109
+ assert(strcmp(s .repository , ' rep1' ));
110
+ assert(strcmp(s .mapping , ' map1' ));
111
+
112
+ s.definition = ' ' ;
113
+ s.repository = ' ' ;
114
+ s.mapping = ' ' ;
115
+ assert(isempty(s .definition ));
116
+ assert(isempty(s .repository ));
117
+ assert(isempty(s .mapping ));
126
118
end
127
119
128
120
function [] = test_properties( varargin )
142
134
143
135
assert(isempty(f.sections{3 }.allProperties));
144
136
end
137
+
138
+ % %Test: set, open and remove section link
139
+ function [] = test_link( varargin )
140
+ f = nix .File(fullfile(pwd , ' tests' , ' testRW.h5' ), nix .FileMode .Overwrite );
141
+ mainSec = f .createSection(' mainSection' , ' nixSection' );
142
+ tmp = f .createSection(' linkSection1' , ' nixSection' );
143
+ tmp = f .createSection(' linkSection2' , ' nixSection' );
144
+
145
+ assert(isempty(mainSec .openLink ));
146
+ mainSec .set_link(f.sections{3 }.id);
147
+ assert(strcmp(mainSec .openLink .name , ' linkSection2' ));
148
+ mainSec .set_link(f.sections{2 });
149
+ assert(strcmp(mainSec .openLink .name , ' linkSection1' ));
150
+
151
+ mainSec .set_link(' ' );
152
+ assert(isempty(mainSec .openLink ));
153
+ end
0 commit comments