10 properties (MethodSetupParameter)
11 argList={{},{
'insertTimestamp',
false},{
'forceon'}};
12 marker={
'',
'insertTimestampFalse',
'forceon'};
15 methods (TestMethodTeardown)
16 function self = tearDown(self)
20 methods (TestMethodSetup,ParameterCombination='sequential')
21 function self=setUp(self,marker,argList)
23 self.resTmpDir=
mxberry.test.TmpDataManager.getDirByCallerKey();
24 self.fileName=[self.resTmpDir,
filesep,'tmp.xml'];
30 self.simpleMetaData=struct('version','0.1','someparam',...
32 self.xmlsaveParams=argList;
38 self = self@
mxberry.unittest.TestCase(varargin{:});
39 metaClass=metaclass(
self);
40 self.locDir=fileparts(which(metaClass.Name));
44 function testTrickySize(
self)
45 Data.alpha={
'alpha'.
'}; 47 Data.theta.gamma={'alpha
'.'};
48 Data.beta=
repmat(
'c',20,30);
49 Data.vega=zeros(2,3,4);
55 self.verifyEqual(
true,isequal(Data,ResData));
59 function testEmpty(
self)
60 expVar=struct('alpha',zeros(1,0));
67 self.verifyEqual(true,isequal(resVar,expVar));
70 function self=testMultidimStructField(self)
74 self.verifyEqual(isequaln(SRes,SData),true);
76 function self = testInteger(self)
78 SData.a=int32([1,2,3]);
79 SData.b=int64([1,2,3]);
80 SData.c=uint64([1,2,3;2 3 3]);
81 SData.d=uint32([1,2,3;4 2 4]);
88 self.
xmlsave(self.fileName,SData);
90 self.verifyEqual(isequaln(SRes,SData),true);
92 function testNegative(self)
94 if verLessThan('matlab','R2016a')
95 checkN(handle([1,2]));
97 checkP(handle([1,2]));
100 checkN(complex([1,2],[1,2]));
101 checkN(complex(int32([1,2]),int32([1,2])));
102 checkN(sparse([1,2]));
104 function checkP(inpArray)
105 SData.alpha=inpArray;
106 self.
xmlsave(self.fileName,SData);
108 function checkN(inpArray)
109 SData.alpha=inpArray; %
#ok<STRNU> 110 self.runAndCheckError(
'self.xmlsave(self.fileName,SData);',...
115 function self = test_complexstructure(
self)
119 self.
xmlsave(self.fileName,Data);
121 self.verifyEqual(isequaln(SRes,Data),true);
122 delete(self.fileName);
125 self.
xmlsave(self.fileName,Data);
127 self.verifyEqual(isequaln(SRes,Data),true);
128 delete(self.fileName);
130 function self = test_complexstructure_backwardcompatibility(self)
132 import
mxberry.test.TmpDataManager;
133 tmpDir=TmpDataManager.getDirByCallerKey();
134 file1ElemShortName='test_complexstructure_1elem.xml';
135 file1ElemName=[self.locDir,
filesep,file1ElemShortName];
136 file1ElemTmpName=[tmpDir,
filesep,file1ElemShortName];
137 fileArrayShortName='test_complexstructure_array.xml';
138 fileArrayName=[self.locDir,
filesep,fileArrayShortName];
139 fileArrayTmpName=[tmpDir,
filesep,fileArrayShortName];
142 self.
xmlsave(file1ElemTmpName,SRes);
143 SResTmp=
xmlload(file1ElemTmpName);
144 self.verifyEqual(isequaln(SRes,SResTmp),true);
145 delete(file1ElemTmpName);
148 self.
xmlsave(fileArrayTmpName,SRes);
149 SResTmp=
xmlload(fileArrayTmpName);
150 self.verifyEqual(isequaln(SRes,SResTmp),true);
151 delete(fileArrayTmpName);
153 function self = test_simple(self)
155 self.
xmlsave(self.fileName,self.simpleData);
157 self.verifyEqual(isequaln(SRes,...
158 self.simpleData),true)
159 delete(self.fileName);
161 function self=test_simple_metadata(self)
163 self.
xmlsave(self.fileName,self.simpleData,'on',self.simpleMetaData);
164 [SRes,SMetaData]=
xmlload(self.fileName);
165 self.verifyTrue(isequaln(SRes,...
167 self.verifyTrue(isequal(SMetaData,...
168 self.simpleMetaData));
170 function self=test_simple_metadata_negative(self)
172 self.runAndCheckError(@runWithFailure,':wrongInput');
174 function runWithFailure()
175 metaData=self.simpleMetaData;
176 metaData.badParam=zeros(1,3);
177 self.
xmlsave(self.fileName,self.simpleData,'on',metaData);
178 self.verifyEqual(true,false);
181 function self = test_parseFormatEmptyStruct(self)
183 self.verifyEqual(true,isequal(....
186 self.verifyEqual(true,isequal(....
192 function
xmlsave(self,filePath,data,varargin)
195 {
'insertTimestamp'});
196 [reg2,prop2]=
mxberry.
core.parseparams(
self.xmlsaveParams);
200 reg=[reg1,reg2(nReg1+1:end)];
204 xmlsave(filePath,data,reg{:},prop1{:},prop2{:});
function xmlload(in fileName)
XMLLOAD loads XML file and converts it into Matlab structure or variable.
function genteststruct(in inpNum)
function repmat(in inpArray, in varargin)
function rmdir(in dirName, in sFlag)
RMDIR removes a directory (optionally recursively)
function xmlformat(in SData, in attSwitch, in name, in level, in SMetaData)
XMLFORMAT formats the variable V into a name-based tag XML string xstr.
function xmlsave(in fileName, in SData, in varargin)
XMLSAVE saves structure or variable(s) to a file using XML format.
function xmlparse(in inpXmlString, in attSwitch, in SData, in level)
XMLPARSE parses XML string str and returns matlab variable/structure. This is a non-validating parser...
function parseparams(in args, in propNameList, in nRegExpected, in nPropExpected)
PARSEPARAMS behaves exactly as a built-in Matlab function apart from the incorrect behavior of Matlab...