|
4 | 4 |
|
5 | 5 | funcs = {};
|
6 | 6 | funcs{end+1} = @test_attrs;
|
| 7 | + funcs{end+1} = @test_update_values; |
7 | 8 | funcs{end+1} = @test_values;
|
8 | 9 | end
|
9 | 10 |
|
|
42 | 43 |
|
43 | 44 | %% Test: Access values
|
44 | 45 | function [] = test_values( varargin )
|
45 |
| - f = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly); |
46 |
| - trial = f.sections{2}.sections{2}.sections{1}; |
47 |
| - currProp = trial.open_property(trial.allProperties{1}.id); |
| 46 | + f = nix.File(fullfile(pwd,'tests','testRW.h5'), nix.FileMode.Overwrite); |
| 47 | + s = f.createSection('mainSection', 'nixSection'); |
| 48 | + currProp = s.create_property_with_value('booleanProperty', {true, false, true}); |
48 | 49 |
|
49 |
| - assert(size(currProp.values, 1) == 1); |
50 |
| - assert(currProp.values{1}.value == 1); |
| 50 | + assert(size(currProp.values, 1) == 3); |
| 51 | + assert(currProp.values{1}.value); |
51 | 52 | assert(currProp.values{1}.uncertainty == 0);
|
52 | 53 | assert(isempty(currProp.values{1}.checksum));
|
53 | 54 | assert(isempty(currProp.values{1}.encoder));
|
54 | 55 | assert(isempty(currProp.values{1}.filename));
|
55 | 56 | assert(isempty(currProp.values{1}.reference));
|
56 |
| - |
57 |
| - disp('Test Property: access values ... TODO (multiple property values)'); |
| 57 | +end |
| 58 | + |
| 59 | +%% Test: Update values |
| 60 | +function [] = test_update_values( varargin ) |
| 61 | + f = nix.File(fullfile(pwd,'tests','testRW.h5'), nix.FileMode.Overwrite); |
| 62 | + s = f.createSection('mainSection', 'nixSection'); |
| 63 | + |
| 64 | + %-- test update boolean |
| 65 | + updateBool = s.create_property_with_value('booleanProperty', {true, false, true}); |
| 66 | + assert(updateBool.values{1}.value); |
| 67 | + updateBool.values{1}.value = false; |
| 68 | + assert(~updateBool.values{1}.value); |
| 69 | + |
| 70 | + %-- test update string |
| 71 | + updateString = s.create_property_with_value('stringProperty', {'this', 'has', 'strings'}); |
| 72 | + assert(strcmp(updateString.values{3}.value, 'strings')); |
| 73 | + updateString.values{3}.value = 'more strings'; |
| 74 | + assert(strcmp(updateString.values{3}.value, 'more strings')); |
| 75 | + |
| 76 | + %-- test update double |
| 77 | + updateDouble = s.create_property_with_value('doubleProperty', {2, 3, 4, 5}); |
| 78 | + assert(updateDouble.values{1}.value == 2); |
| 79 | + updateDouble.values{1}.value = 2.2; |
| 80 | + assert(updateDouble.values{1}.value == 2.2); |
58 | 81 | end
|
0 commit comments