-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtgenerateSimFun.m
More file actions
65 lines (48 loc) · 1.99 KB
/
Copy pathtgenerateSimFun.m
File metadata and controls
65 lines (48 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
classdef tgenerateSimFun < matlab.unittest.TestCase
properties (Access=private)
MATfilefullpath
LoadedData
end
properties (ClassSetupParameter)
MATfilename = {"test_generateSimFun.mat", string.empty}
end
properties (TestParameter)
fieldName = {"simFun","doseTable","dependenciesSimFun"}
end
methods (Test)
function testMATfileCreation(testCase)
import matlab.unittest.constraints.IsFile;
% Verify that the MAT file is created
testCase.verifyThat(testCase.MATfilefullpath, IsFile, ...
'MAT file was not created.');
end
function testSimFunctionCreation(testCase, fieldName)
import matlab.unittest.constraints.HasField;
% Verify that the MAT file contains required fields
testCase.verifyThat(testCase.LoadedData, HasField(fieldName), ...
fieldName + " should be saved in " + testCase.MATfilefullpath);
end
function testSimFunctionAcceleration(testCase)
% Verify that the SimFunction is accelerated
simFun = testCase.LoadedData.simFun;
testCase.verifyReturnsTrue(@()simFun.isAccelerated, ...
"simFun was not accelerated.");
end
end
methods (TestClassSetup)
function classSetup(testCase, MATfilename)
% Set up shared state for all tests.
import matlab.unittest.fixtures.WorkingFolderFixture;
% Call generateSimFun without or with input argument
if isempty(MATfilename)
testCase.MATfilefullpath = generateSimFun();
else
% Generate the simulation function in a working folder
testCase.applyFixture(WorkingFolderFixture);
testCase.MATfilefullpath = generateSimFun(MATfilename);
end
% Load content of MAT file
testCase.LoadedData = load(testCase.MATfilefullpath);
end
end
end