-
Notifications
You must be signed in to change notification settings - Fork 42
/
testYamlConversion.m
41 lines (33 loc) · 1.21 KB
/
testYamlConversion.m
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
function status = testYamlConversion
% test the functions for yaml import/export see if the conversion process
% changes the model content
%
% Get model path
[ST, I]=dbstack('-completenames');
modelPath=fileparts(fileparts(fileparts(ST(I).file)));
% export to yml and then import back
try
% Import yaml model
ymlFile=fullfile(modelPath,'model','Human-GEM.yml');
model = importYaml(ymlFile, true);
% make sure there is no intermediate Yaml file under the current folder
warning('off', 'MATLAB:DELETE:FileNotFound')
if exist('testYamlConversion.yml','file')
delete testYamlConversion.yml;
end
exportYaml(model,'testYamlConversion.yml');
importedHumanGEM = importYaml('testYamlConversion.yml', true);
% remove intermediate Yaml file
delete testYamlConversion.yml;
% compare the imported model from yaml with the original one
if ~isequal(model, importedHumanGEM)
warning('::error::Re-imported model is diffrent from export');
exit(1);
end
catch
warning('::error::There are problems during the conversion import and export');
exit(1)
end
% model conversion between Matlab and Yaml files is successful
disp('The conversion was successful.')
exit(0)