Home > testing > unit_tests > importExportTests.m

importExportTests

PURPOSE ^

run this test case with the command

SYNOPSIS ^

function tests = importExportTests

DESCRIPTION ^

run this test case with the command
results = runtests('importExportTests.m')

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %run this test case with the command
0002 %results = runtests('importExportTests.m')
0003 function tests = importExportTests
0004 tests = functiontests(localfunctions);
0005 end
0006 
0007 function testExcelImport(testCase)
0008 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0009 excelFile=fullfile(sourceDir,'tutorial','empty.xlsx');
0010 %%Prepare test results, uncomment and run when new reference is needed
0011 % modelExcel=importExcelModel(excelFile);
0012 % sbmlFile=fullfile(sourceDir,'tutorial','empty.xml');
0013 % modelSBML=importModel(sbmlFile);
0014 % save(fullfile(sourceDir,'testing','unit_tests','test_data','importExportResults.mat'),'modelExcel','modelSBML');
0015 evalc('model=importExcelModel(excelFile)'); % Repress warnings
0016 load(fullfile(sourceDir,'testing','unit_tests','test_data','importExportResults.mat'), 'modelExcel');
0017 verifyEqual(testCase,model,modelExcel)
0018 end
0019 
0020 function testSBMLImport(testCase)
0021 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0022 sbmlFile=fullfile(sourceDir,'tutorial','empty.xml');
0023 evalc('model=importModel(sbmlFile)'); % Repress warnings
0024 load(fullfile(sourceDir,'testing','unit_tests','test_data','importExportResults.mat'), 'modelSBML');
0025 verifyEqual(testCase,model,modelSBML)
0026 end
0027 
0028 function testExcelExport(testCase)
0029 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0030 load(fullfile(sourceDir,'testing','unit_tests','test_data','ecoli_textbook.mat'), 'model');
0031 exportToExcelFormat(model,fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx'));
0032 %File will not be exactly equal as it contains the current date and time,
0033 %so md5 or similar would not work. Just check whether file is reasonably
0034 %sized.
0035 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx'));         
0036 filesize = s.bytes;
0037 verifyTrue(testCase,filesize>17000);
0038 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xlsx'));
0039 end
0040 
0041 function testSBMLExport(testCase)
0042 sourceDir=fileparts(fileparts(fileparts(which(mfilename))));
0043 load(fullfile(sourceDir,'testing','unit_tests','test_data','ecoli_textbook.mat'), 'model');
0044 evalc('exportModel(model,fullfile(sourceDir,''testing'',''unit_tests'',''test_data'',''_test.xml''))');
0045 %File will not be exactly equal as it contains the current date and time,
0046 %so md5 or similar would not work. Just check whether file is reasonably
0047 %sized.
0048 s = dir(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xml'));         
0049 filesize = s.bytes;
0050 verifyTrue(testCase,filesize>18500);
0051 delete(fullfile(sourceDir,'testing','unit_tests','test_data','_test.xml'));
0052 end

Generated by m2html © 2005