1
+ function funcs = TestDimensions
2
+ % TestDimensions tests for Dimensions
3
+ % Detailed explanation goes here
4
+
5
+ funcs = {};
6
+ funcs{end + 1 } = @test_set_dimension ;
7
+ funcs{end + 1 } = @test_sample_dimension ;
8
+ funcs{end + 1 } = @test_range_dimension ;
9
+ end
10
+
11
+ function [] = test_set_dimension( varargin )
12
+ %% Test: set dimension
13
+ f = nix .File(fullfile(pwd , ' tests' , ' testRW.h5' ), nix .FileMode .Overwrite );
14
+ b = f .createBlock(' daTestBlock' , ' test nixBlock' );
15
+ da = b .create_data_array(' daTest' , ' test nixDataArray' , ' double' , [1 2 ]);
16
+ d1 = da .append_set_dimension();
17
+
18
+ assert(strcmp(d1 .dimensionType , ' set' ));
19
+ assert(isempty(d1 .labels ));
20
+
21
+ d1.labels = {' foo' , ' bar' };
22
+ assert(strcmp(d1.labels{1 }, ' foo' ));
23
+ assert(strcmp(d1.labels{2 }, ' bar' ));
24
+
25
+ % fix this in NIX
26
+ % d1.labels = {};
27
+ % assert(isempty(d1.labels));
28
+ end
29
+
30
+ function [] = test_sample_dimension( varargin )
31
+ %% Test: sampled dimension
32
+ f = nix .File(fullfile(pwd , ' tests' , ' testRW.h5' ), nix .FileMode .Overwrite );
33
+ b = f .createBlock(' daTestBlock' , ' test nixBlock' );
34
+ da = b .create_data_array(' daTest' , ' test nixDataArray' , ' double' , [1 2 ]);
35
+ d1 = da .append_sampled_dimension(200 );
36
+
37
+ assert(strcmp(d1 .dimensionType , ' sample' ));
38
+ assert(isempty(d1 .label ));
39
+ assert(isempty(d1 .unit ));
40
+ assert(d1 .samplingInterval == 200 );
41
+ assert(isempty(d1 .offset ));
42
+
43
+ d1.label = ' foo' ;
44
+ d1.unit = ' mV' ;
45
+ d1.samplingInterval = 325 ;
46
+ d1.offset = 500 ;
47
+
48
+ assert(strcmp(d1 .label , ' foo' ));
49
+ assert(strcmp(d1 .unit , ' mV' ));
50
+ assert(d1 .samplingInterval == 325 );
51
+ assert(d1 .offset == 500 );
52
+
53
+ d1.label = ' ' ;
54
+ d1.unit = ' ' ;
55
+ d1.offset = 0 ;
56
+
57
+ assert(isempty(d1 .label ));
58
+ assert(isempty(d1 .unit ));
59
+ assert(d1 .samplingInterval == 325 );
60
+ assert(d1 .offset == 0 );
61
+ end
62
+
63
+ function [] = test_range_dimension( varargin )
64
+ %% Test: range dimension
65
+ f = nix .File(fullfile(pwd , ' tests' , ' testRW.h5' ), nix .FileMode .Overwrite );
66
+ b = f .createBlock(' daTestBlock' , ' test nixBlock' );
67
+ da = b .create_data_array(' daTest' , ' test nixDataArray' , ' double' , [1 2 ]);
68
+ ticks = [1 2 3 4 ];
69
+ d1 = da .append_range_dimension(ticks );
70
+
71
+ assert(strcmp(d1 .dimensionType , ' range' ));
72
+ assert(isempty(d1 .label ));
73
+ assert(isempty(d1 .unit ));
74
+ assert(isequal(d1 .ticks , ticks ));
75
+
76
+ new_ticks = [5 6 7 8 ];
77
+ d1.label = ' foo' ;
78
+ d1.unit = ' mV' ;
79
+ d1.ticks = new_ticks ;
80
+
81
+ assert(strcmp(d1 .label , ' foo' ));
82
+ assert(strcmp(d1 .unit , ' mV' ));
83
+ assert(isequal(d1 .ticks , new_ticks ));
84
+
85
+ d1.label = ' ' ;
86
+ d1.unit = ' ' ;
87
+
88
+ assert(isempty(d1 .label ));
89
+ assert(isempty(d1 .unit ));
90
+ end
0 commit comments