Skip to content

Commit 4054e2f

Browse files
committed
[Matlab] Refactor SourcesMixIn index use
1 parent de07207 commit 4054e2f

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

+nix/SourcesMixIn.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
r = nix.Utils.open_entity(obj, 'openSource', id_or_name, @nix.Source);
4646
end
4747

48-
function r = open_source_idx(obj, idx)
48+
function r = open_source_idx(obj, index)
49+
idx = nix.Utils.handle_index(index);
4950
r = nix.Utils.open_entity(obj, 'openSourceIdx', idx, @nix.Source);
5051
end
5152

tests/TestDataArray.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,9 @@
384384
d.add_source(s2);
385385
d.add_source(s3);
386386

387-
assert(strcmp(f.blocks{1}.dataArrays{1}.open_source_idx(0).name, s1.name));
388-
assert(strcmp(f.blocks{1}.dataArrays{1}.open_source_idx(1).name, s2.name));
389-
assert(strcmp(f.blocks{1}.dataArrays{1}.open_source_idx(2).name, s3.name));
387+
assert(strcmp(f.blocks{1}.dataArrays{1}.open_source_idx(1).name, s1.name));
388+
assert(strcmp(f.blocks{1}.dataArrays{1}.open_source_idx(2).name, s2.name));
389+
assert(strcmp(f.blocks{1}.dataArrays{1}.open_source_idx(3).name, s3.name));
390390
end
391391

392392
%% Test: Remove sources by entity and id

tests/TestGroup.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,9 @@
854854
g.add_source(s2);
855855
g.add_source(s3);
856856

857-
assert(strcmp(f.blocks{1}.groups{1}.open_source_idx(0).name, s1.name));
858-
assert(strcmp(f.blocks{1}.groups{1}.open_source_idx(1).name, s2.name));
859-
assert(strcmp(f.blocks{1}.groups{1}.open_source_idx(2).name, s3.name));
857+
assert(strcmp(f.blocks{1}.groups{1}.open_source_idx(1).name, s1.name));
858+
assert(strcmp(f.blocks{1}.groups{1}.open_source_idx(2).name, s2.name));
859+
assert(strcmp(f.blocks{1}.groups{1}.open_source_idx(3).name, s3.name));
860860
end
861861

862862
function [] = test_compare( varargin )

tests/TestMultiTag.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@
360360
t.add_source(s2);
361361
t.add_source(s3);
362362

363-
assert(strcmp(f.blocks{1}.multiTags{1}.open_source_idx(0).name, s1.name));
364-
assert(strcmp(f.blocks{1}.multiTags{1}.open_source_idx(1).name, s2.name));
365-
assert(strcmp(f.blocks{1}.multiTags{1}.open_source_idx(2).name, s3.name));
363+
assert(strcmp(f.blocks{1}.multiTags{1}.open_source_idx(1).name, s1.name));
364+
assert(strcmp(f.blocks{1}.multiTags{1}.open_source_idx(2).name, s2.name));
365+
assert(strcmp(f.blocks{1}.multiTags{1}.open_source_idx(3).name, s3.name));
366366
end
367367

368368
%% Test: has nix.Source by ID or entity

tests/TestTag.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@
371371
t.add_source(s2);
372372
t.add_source(s3);
373373

374-
assert(strcmp(f.blocks{1}.tags{1}.open_source_idx(0).name, s1.name));
375-
assert(strcmp(f.blocks{1}.tags{1}.open_source_idx(1).name, s2.name));
376-
assert(strcmp(f.blocks{1}.tags{1}.open_source_idx(2).name, s3.name));
374+
assert(strcmp(f.blocks{1}.tags{1}.open_source_idx(1).name, s1.name));
375+
assert(strcmp(f.blocks{1}.tags{1}.open_source_idx(2).name, s2.name));
376+
assert(strcmp(f.blocks{1}.tags{1}.open_source_idx(3).name, s3.name));
377377
end
378378

379379
%% Test: nix.Tag has nix.Source by ID or entity

0 commit comments

Comments
 (0)