1
% Generates mat files for loadmat unit tests
2
% This is the version for matlab 5 and higher
3
% Uses save_test.m function
5
% work out matlab version and file suffix for test files
6
global FILEPREFIX FILESUFFIX
7
FILEPREFIX = [fullfile(pwd, 'data') filesep];
10
FILESUFFIX = ['_' mlv '_' computer '.mat'];
13
save_test('testdouble', 0:pi/4:2*pi);
16
save_test('teststring', '"Do nine men interpret?" "Nine men," I nod.')
20
save_test('testcomplex', cos(theta) + 1j*sin(theta));
22
% asymmetric array to check indexing
28
save_test('testmatrix', a);
30
% minus number - tests signed int
31
save_test('testminus', -1);
34
save_test('testonechar', 'r');
37
save_test('teststringarray', ['one '; 'two '; 'three']);
40
save_test('testsparse', sparse(a));
42
% sparse complex array
45
save_test('testsparsecomplex', b);
47
% Two variables in same file
48
save([FILEPREFIX 'testmulti' FILESUFFIX], 'a', 'theta')
52
save_test('teststruct', ...
53
struct('stringfield','Rats live on no evil star.',...
54
'doublefield',[sqrt(2) exp(1) pi],...
55
'complexfield',(1+1j)*[sqrt(2) exp(1) pi]));
58
save_test('testcell', ...
59
{['This cell contains this string and 3 arrays of increasing' ...
60
' length'], 1., 1.:2., 1.:3.});
62
% Empty cells in two cell matrices
63
save_test('testemptycell', {1, 2, [], [], 3});
66
save_test('test3dmatrix', reshape(1:24,[2 3 4]))
69
save_test('testcellnest', {1, {2, 3, {4, 5}}});
72
save_test('teststructnest', struct('one', 1, 'two', ...
73
struct('three', 'number 3')));
76
save_test('teststructarr', [struct('one', 1, 'two', 2) ...
77
struct('one', 'number 1', 'two', 'number 2')]);
80
save_test('testobject', inline('x'))
82
% array of matlab objects
83
%save_test('testobjarr', [inline('x') inline('y')])
86
if str2num(mlv) > 7 % function added 7.0.1
87
fid = fopen([FILEPREFIX 'japanese_utf8.txt']);
88
from_japan = fread(fid, 'uint8')';
90
save_test('testunicode', native2unicode(from_japan, 'utf-8'));
b'\\ No newline at end of file'