@@ -10,10 +10,11 @@ function addPaths(testCase)
1010 methods (Static )
1111 function ms = makeMetadataStruct(stateKeys , nPoints )
1212 % MAKEMETADATASTRUCT Build a fake metadata struct for testing.
13- ms.doc.date = ' time_utc' ;
1413 ms.time_utc = linspace(datenum(2024 ,1 ,1 ), datenum(2024 ,1 ,2 ), nPoints );
1514 for i = 1 : numel(stateKeys )
1615 ms.(stateKeys{i }) = zeros(1 , nPoints );
16+ ms .doc.(stateKeys{i }).name = stateKeys{i };
17+ ms .doc.(stateKeys{i }).datum = ' time_utc' ;
1718 end
1819 end
1920
@@ -53,7 +54,8 @@ function testCellStringState(testCase)
5354 s = TestLoadModuleMetadata .makeSensorWithRule( ...
5455 ' temp' , struct(' recipe' , ' bake' ), 80 );
5556
56- ms.doc.date = ' time_utc' ;
57+ ms.doc.recipe.name = ' recipe' ;
58+ ms.doc.recipe.datum = ' time_utc' ;
5759 ms.time_utc = linspace(datenum(2024 ,1 ,1 ), datenum(2024 ,1 ,2 ), 6 );
5860 ms.recipe = {' idle' , ' idle' , ' bake' , ' bake' , ' bake' , ' idle' };
5961
@@ -156,7 +158,8 @@ function testSinglePointMetadata(testCase)
156158 s = TestLoadModuleMetadata .makeSensorWithRule( ...
157159 ' temp' , struct(' machine' , 1 ), 50 );
158160
159- ms.doc.date = ' time_utc' ;
161+ ms.doc.machine.name = ' machine' ;
162+ ms.doc.machine.datum = ' time_utc' ;
160163 ms.time_utc = datenum(2024 ,1 ,1 );
161164 ms.machine = 1 ;
162165
@@ -172,7 +175,8 @@ function testColumnVectorInputs(testCase)
172175 s = TestLoadModuleMetadata .makeSensorWithRule( ...
173176 ' temp' , struct(' machine' , 1 ), 50 );
174177
175- ms.doc.date = ' time_utc' ;
178+ ms.doc.machine.name = ' machine' ;
179+ ms.doc.machine.datum = ' time_utc' ;
176180 ms.time_utc = linspace(datenum(2024 ,1 ,1 ), datenum(2024 ,1 ,2 ), 6 )' ;
177181 ms.machine = [0 ; 0 ; 1 ; 1 ; 0 ; 0 ];
178182
@@ -200,20 +204,23 @@ function testMissingDocErrors(testCase)
200204 testCase .verifyTrue(threw , ' missing_doc_throws' );
201205 end
202206
203- function testMissingDocDateErrors(testCase )
204- ms = struct(' doc' , struct(' version' , ' 1.0' ), ' machine' , [1 2 3 ]);
207+ function testDocMissingDatumErrors(testCase )
208+ % doc entry without .datum field
209+ ms.doc.machine.name = ' machine' ; % no .datum
210+ ms.machine = [1 2 3 ];
205211 threw = false ;
206212 try
207213 loadModuleMetadata(ms , {});
208214 catch
209215 threw = true ;
210216 end
211- testCase .verifyTrue(threw , ' missing_doc_date_throws ' );
217+ testCase .verifyTrue(threw , ' missing_datum_throws ' );
212218 end
213219
214- function testDocDateNotInStructErrors(testCase )
215- ms = struct(' doc' , struct(' date' , ' nonexistent' ), ...
216- ' machine' , [1 2 3 ]);
220+ function testDatenumFieldNotInStructErrors(testCase )
221+ ms.doc.machine.name = ' machine' ;
222+ ms.doc.machine.datum = ' nonexistent' ;
223+ ms.machine = [1 2 3 ];
217224 threw = false ;
218225 try
219226 loadModuleMetadata(ms , {});
@@ -223,16 +230,18 @@ function testDocDateNotInStructErrors(testCase)
223230 testCase .verifyTrue(threw , ' bad_datenum_ref_throws' );
224231 end
225232
226- function testDocDateNotCharErrors(testCase )
227- % Defensive test beyond spec scope
228- ms = struct(' doc' , struct(' date' , 42 ), ' machine' , [1 2 3 ]);
233+ function testDatumNotCharErrors(testCase )
234+ % Defensive test: validates datum type
235+ ms.doc.machine.name = ' machine' ;
236+ ms.doc.machine.datum = 42 ;
237+ ms.machine = [1 2 3 ];
229238 threw = false ;
230239 try
231240 loadModuleMetadata(ms , {});
232241 catch
233242 threw = true ;
234243 end
235- testCase .verifyTrue(threw , ' non_char_date_throws ' );
244+ testCase .verifyTrue(threw , ' non_char_datum_throws ' );
236245 end
237246
238247 function testOutputRowOrientation(testCase )
0 commit comments