~ubuntu-branches/ubuntu/raring/scilab/raring-proposed

« back to all changes in this revision

Viewing changes to modules/matio/tests/unit_tests/loadmatfile.dia.ref

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-30 14:42:38 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20120830144238-c1y2og7dbm7m9nig
Tags: 5.4.0-beta-3-1~exp1
* New upstream release
* Update the scirenderer dep
* Get ride of libjhdf5-java dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
  // TESTS FOR CELL ARRAYS
21
21
  //
22
22
  if binFormats(formatIndex) <> "-v4" then // Cell arrays can not be stored in Matlab 4 binary files
23
 
    if or(emptycell <> cell()) then bugmes();quit;end
24
 
    if or(scalarcell <> makecell([1 1], 1.23)) then bugmes();quit;end
25
 
    if or(rowcell <> makecell([1 3], "abc", [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i], 1.23)) then bugmes();quit;end
26
 
    if or(colcell <> makecell([3 1], [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i], "abc", 1.23)) then bugmes();quit;end
27
 
    if or(arraycell <> makecell([2 3], "a", [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i], int8(1), "abc", 1.23, eye(100,100))) then bugmes();quit;end
28
 
    if or(stringcell <> makecell([2 3], "abc", "def", "ghi", "jkl", "mno", "pqr")) then bugmes();quit;end
 
23
    assert_checkequal(emptycell , cell());
 
24
    assert_checkequal(scalarcell , makecell([1 1], 1.23));
 
25
    assert_checkequal(rowcell , makecell([1 3], "abc", [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i], 1.23));
 
26
    assert_checkequal(colcell , makecell([3 1], [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i], "abc", 1.23));
 
27
    assert_checkequal(arraycell , makecell([2 3], "a", [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i], int8(1), "abc", 1.23, eye(100,100)));
 
28
    assert_checkequal(stringcell , makecell([2 3], "abc", "def", "ghi", "jkl", "mno", "pqr"));
29
29
    clear emptycell scalarcell rowcell colcell arraycell stringcell
30
30
  end
31
31
  //
33
33
  //
34
34
  if binFormats(formatIndex) <> "-v4" then // Struct arrays can not be stored in Matlab 4 binary files
35
35
    sciemptystruct = struct();
36
 
    if or(emptystruct <> sciemptystruct) then bugmes();quit;end
 
36
    assert_checkequal(emptystruct , sciemptystruct);
37
37
    sciscalarstruct = struct("f1", 10, "ftwo", "Hello", "field3", int8(12));
38
 
    if or(scalarstruct <> sciscalarstruct) then bugmes();quit;end
 
38
    assert_checkequal(scalarstruct , sciscalarstruct);
39
39
    scirowstruct = struct("field1", 10, "field2", "Hello", "field3", int8(12));
40
40
    scirowstruct(1,2).field1 = "test";
41
41
    scirowstruct(1,2).field2 = eye(10, 10);
42
42
    scirowstruct(1,3).field2 = "a field contents";
43
43
    scirowstruct(1,3).field3 = 1.23+4.56*%i;
44
 
    if or(rowstruct <> scirowstruct) then bugmes();quit;end
 
44
    assert_checkequal(rowstruct , scirowstruct);
45
45
    scicolstruct = struct("name", 10, "phone", "Hello", "address", int8(12));
46
46
    scicolstruct(2,1).name = "test";
47
47
    scicolstruct(2,1).phone = eye(10, 10);
48
48
    scicolstruct(3,1).phone = "a field contents";
49
49
    scicolstruct(3,1).address = 1.23+4.56*%i;
50
 
    if or(colstruct <> scicolstruct) then bugmes();quit;end
 
50
    assert_checkequal(colstruct , scicolstruct);
51
51
    sciarraystruct = struct("field1", 10, "field2", "Hello", "field3", int8(12));
52
52
    sciarraystruct(1,2).field1 = "test";
53
53
    sciarraystruct(1,2).field2 = eye(10, 10);
57
57
    sciarraystruct(2,1).phone = eye(10, 10);
58
58
    sciarraystruct(3,1).phone = "a field contents";
59
59
    sciarraystruct(3,1).address = 1.23+4.56*%i;
60
 
    if or(arraystruct <> sciarraystruct) then bugmes();quit;end
 
60
    assert_checkequal(arraystruct , sciarraystruct);
61
61
    clear emptystruct scalarstruct rowstruct colstruct arraystruct
62
62
    clear sciemptystruct sciscalarstruct scirowstruct scicolstruct sciarraystruct
63
63
  end
68
68
  //
69
69
  // TESTS FOR CHARACTER ARRAYS
70
70
  //
71
 
  if or(emptystringmatrix <> "") then bugmes();quit;end
72
 
  if or(stringscalar <> "a") then bugmes();quit;end
73
 
  if or(stringrowvector <> ["abc"]) then bugmes();quit;end
74
 
  if or(stringcolvector <> ["a";"b";"c"]) then bugmes();quit;end
75
 
  if or(stringmatrix <> ["abc";"def"]) then bugmes();quit;end
 
71
  assert_checkequal(emptystringmatrix , "");
 
72
  assert_checkequal(stringscalar , "a");
 
73
  assert_checkequal(stringrowvector , ["abc"]);
 
74
  assert_checkequal(stringcolvector , ["a";"b";"c"]);
 
75
  assert_checkequal(stringmatrix , ["abc";"def"]);
76
76
  clear emptystringmatrix stringscalar stringrowvector stringcolvector stringmatrix
77
77
  //
78
78
  // TESTS FOR DOUBLE PRECISION ARRAYS
79
79
  //
80
 
  if or(emptydoublematrix <> []) then bugmes();quit;end
81
 
  if or(realdoublescalar <> 1.23) then bugmes();quit;end
82
 
  if or(cplxdoublescalar <> 1.23 + 4.56*%i) then bugmes();quit;end
83
 
  if or(realdoublerowvector <> [1.23 -4.56 7.89]) then bugmes();quit;end
84
 
  if or(cplxdoublerowvector <> [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i]) then bugmes();quit;end
85
 
  if or(realdoublecolvector <> [1.23;-4.56;7.89]) then bugmes();quit;end
86
 
  if or(cplxdoublecolvector <> [1.23+7.89*%i;4.56-1.23*%i;7.89+4.56*%i]) then bugmes();quit;end
87
 
  if or(realdoublematrix <> [1.23 -4.56 7.89;9.87 6.54 -3.21]) then bugmes();quit;end
88
 
  if or(cplxdoublematrix <> [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i;9.87+3.21*%i 6.54+9.87*%i 3.21-6.54*%i]) then bugmes();quit;end
 
80
  assert_checkequal(emptydoublematrix , []);
 
81
  assert_checkequal(realdoublescalar , 1.23);
 
82
  assert_checkequal(cplxdoublescalar , 1.23 + 4.56*%i);
 
83
  assert_checkequal(realdoublerowvector , [1.23 -4.56 7.89]);
 
84
  assert_checkequal(cplxdoublerowvector , [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i]);
 
85
  assert_checkequal(realdoublecolvector , [1.23;-4.56;7.89]);
 
86
  assert_checkequal(cplxdoublecolvector , [1.23+7.89*%i;4.56-1.23*%i;7.89+4.56*%i]);
 
87
  assert_checkequal(realdoublematrix , [1.23 -4.56 7.89;9.87 6.54 -3.21]);
 
88
  assert_checkequal(cplxdoublematrix , [1.23+7.89*%i 4.56-1.23*%i 7.89+4.56*%i;9.87+3.21*%i 6.54+9.87*%i 3.21-6.54*%i]);
89
89
  clear emptydoublematrix realdoublescalar cplxdoublescalar realdoublerowvector cplxdoublerowvector realdoublecolvector cplxdoublecolvector realdoublematrix cplxdoublematrix
90
90
  //
91
91
  // TESTS FOR SINGLE PRECISION ARRAYS
95
95
  // TESTS FOR SPARSE MATRICES
96
96
  //
97
97
  if binFormats(formatIndex) <> "-v4" then // Integers can not be stored in Matlab 4 binary files
98
 
  if or(emptysparse <> []) then bugmes();quit;end
99
 
  if or(realscalarsparse <> sparse(1.23)) then bugmes();quit;end
100
 
  //if or(cplxscalarsparse <> sparse(1.23 + 4.56i)) then bugmes();quit;end
101
 
  if or(realrowvectorsparse <> sparse([1.23 0 7.89])) then bugmes();quit;end
102
 
  //if or(cplxrowvectorsparse <> sparse([1.23+7.89i 0 7.89+4.56i])) then bugmes();quit;end
103
 
  if or(realcolvectorsparse <> sparse([1.23;0;7.89])) then bugmes();quit;end
104
 
  //if or(cplxcolvectorsparse <> sparse([1.23+7.89i;;7.89+4.56i])) then bugmes();quit;end
105
 
  if or(realmatrixsparse <> sparse([1.23 0 7.89;0 6.54 -3.21])) then bugmes();quit;end
106
 
  //if or(cplxmatrixsparse <> sparse([1.23+7.89i 0 7.89+4.56i;0 6.54+9.87i 3.21-6.54i])) then bugmes();quit;end
 
98
  assert_checkequal(emptysparse , []);
 
99
  assert_checkequal(realscalarsparse , sparse(1.23));
 
100
  //assert_checkequal(cplxscalarsparse , sparse(1.23 + 4.56i));
 
101
  assert_checkequal(realrowvectorsparse , sparse([1.23 0 7.89]));
 
102
  //assert_checkequal(cplxrowvectorsparse , sparse([1.23+7.89i 0 7.89+4.56i]));
 
103
  assert_checkequal(realcolvectorsparse , sparse([1.23;0;7.89]));
 
104
  //assert_checkequal(cplxcolvectorsparse , sparse([1.23+7.89i;;7.89+4.56i]));
 
105
  assert_checkequal(realmatrixsparse , sparse([1.23 0 7.89;0 6.54 -3.21]));
 
106
  //assert_checkequal(cplxmatrixsparse , sparse([1.23+7.89i 0 7.89+4.56i;0 6.54+9.87i 3.21-6.54i]));
107
107
end
108
108
  if binFormats(formatIndex) <> "-v4" then // Integers can not be stored in Matlab 4 binary files
109
109
    //
110
110
    // TESTS FOR 8-BITS SIGNED INTEGERS
111
111
    //
112
 
    if or(emptyint8matrix <> int8([])) then bugmes();quit;end
113
 
    if or(int8scalar <> int8(1)) then bugmes();quit;end
114
 
    if or(int8rowvector <> int8([1 -4 7])) then bugmes();quit;end
115
 
    if or(int8colvector <> int8([1;-4;7])) then bugmes();quit;end
116
 
    if or(int8matrix <> int8([1 -4 7;-9 6 -3])) then bugmes();quit;end
 
112
    assert_checkequal(emptyint8matrix , int8([]));
 
113
    assert_checkequal(int8scalar , int8(1));
 
114
    assert_checkequal(int8rowvector , int8([1 -4 7]));
 
115
    assert_checkequal(int8colvector , int8([1;-4;7]));
 
116
    assert_checkequal(int8matrix , int8([1 -4 7;-9 6 -3]));
117
117
    clear emptyint8matrix int8scalar int8rowvector int8colvector int8matrix
118
118
    //
119
119
    // TESTS FOR 16-BITS SIGNED INTEGERS
120
120
    //
121
 
    if or(emptyint16matrix <> int16([])) then bugmes();quit;end
122
 
    if or(int16scalar <> int16(1)) then bugmes();quit;end
123
 
    if or(int16rowvector <> int16([1 -4 7])) then bugmes();quit;end
124
 
    if or(int16colvector <> int16([1;-4;7])) then bugmes();quit;end
125
 
    if or(int16matrix <> int16([1 -4 7;-9 6 -3])) then bugmes();quit;end
 
121
    assert_checkequal(emptyint16matrix , int16([]));
 
122
    assert_checkequal(int16scalar , int16(1));
 
123
    assert_checkequal(int16rowvector , int16([1 -4 7]));
 
124
    assert_checkequal(int16colvector , int16([1;-4;7]));
 
125
    assert_checkequal(int16matrix , int16([1 -4 7;-9 6 -3]));
126
126
    clear emptyint16matrix int16scalar int16rowvector int16colvector int16matrix
127
127
    //
128
128
    // TESTS FOR 32-BITS SIGNED INTEGERS
129
129
    //
130
 
    if or(emptyint32matrix <> int32([])) then bugmes();quit;end
131
 
    if or(int32scalar <> int32(1)) then bugmes();quit;end
132
 
    if or(int32rowvector <> int32([1 -4 7])) then bugmes();quit;end
133
 
    if or(int32colvector <> int32([1;-4;7])) then bugmes();quit;end
134
 
    if or(int32matrix <> int32([1 -4 7;-9 6 -3])) then bugmes();quit;end
 
130
    assert_checkequal(emptyint32matrix , int32([]));
 
131
    assert_checkequal(int32scalar , int32(1));
 
132
    assert_checkequal(int32rowvector , int32([1 -4 7]));
 
133
    assert_checkequal(int32colvector , int32([1;-4;7]));
 
134
    assert_checkequal(int32matrix , int32([1 -4 7;-9 6 -3]));
135
135
    clear emptyint32matrix int32scalar int32rowvector int32colvector int32matrix
136
136
    // TODO: int64 tests ?
137
137
    //
138
138
    // TESTS FOR 8-BITS UNSIGNED INTEGERS
139
139
    //
140
 
    if or(emptyuint8matrix <> uint8([])) then bugmes();quit;end
141
 
    if or(uint8scalar <> uint8(1)) then bugmes();quit;end
142
 
    //if or(uint8rowvector <> uint8([1 -4 7])) then bugmes();quit;end
143
 
    if or(uint8rowvector <> [1 0 7]) then bugmes();quit;end
144
 
    //if or(uint8colvector <> uint8([1;-4;7])) then bugmes();quit;end
145
 
    if or(uint8colvector <> [1;0;7]) then bugmes();quit;end
146
 
    //if or(uint8matrix <> uint8([1 -4 7;-9 6 -3])) then bugmes();quit;end
147
 
    if or(uint8matrix <> [1 0 7;0 6 0]) then bugmes();quit;end
 
140
    assert_checkequal(emptyuint8matrix , uint8([]));
 
141
    assert_checkequal(uint8scalar , uint8(1));
 
142
    //assert_checkequal(uint8rowvector , uint8([1 -4 7]));
 
143
    assert_checkequal(uint8rowvector , uint8([1 0 7]));
 
144
    //assert_checkequal(uint8colvector , uint8([1;-4;7]));
 
145
    assert_checkequal(uint8colvector , uint8([1;0;7]));
 
146
    //assert_checkequal(uint8matrix , uint8([1 -4 7;-9 6 -3]));
 
147
    assert_checkequal(uint8matrix , uint8([1 0 7;0 6 0]));
148
148
    clear emptyuint8matrix uint8scalar uint8rowvector uint8colvector uint8matrix
149
149
    //
150
150
    // TESTS FOR 16-BITS UNSIGNED INTEGERS
151
151
    //
152
 
    if or(emptyuint16matrix <> uint16([])) then bugmes();quit;end
153
 
    if or(uint16scalar <> uint16(1)) then bugmes();quit;end
154
 
    //if or(uint16rowvector <> uint16([1 -4 7])) then bugmes();quit;end
155
 
    if or(uint16rowvector <> [1 0 7]) then bugmes();quit;end
156
 
    //if or(uint16colvector <> uint16([1;-4;7])) then bugmes();quit;end
157
 
    if or(uint16colvector <> [1;0;7]) then bugmes();quit;end
158
 
    //if or(uint16matrix <> uint16([1 -4 7;-9 6 -3])) then bugmes();quit;end
159
 
    if or(uint16matrix <> [1 0 7;0 6 0]) then bugmes();quit;end
 
152
    assert_checkequal(emptyuint16matrix , uint16([]));
 
153
    assert_checkequal(uint16scalar , uint16(1));
 
154
    //assert_checkequal(uint16rowvector , uint16([1 -4 7]));
 
155
    assert_checkequal(uint16rowvector , uint16([1 0 7]));
 
156
    //assert_checkequal(uint16colvector , uint16([1;-4;7]));
 
157
    assert_checkequal(uint16colvector , uint16([1;0;7]));
 
158
    //assert_checkequal(uint16matrix , uint16([1 -4 7;-9 6 -3]));
 
159
    assert_checkequal(uint16matrix , uint16([1 0 7;0 6 0]));
160
160
    clear emptyuint16matrix uint16scalar uint16rowvector uint16colvector uint16matrix
161
161
    //
162
162
    // TESTS FOR 32-BITS UNSIGNED INTEGERS
163
163
    //
164
 
    if or(emptyuint32matrix <> uint32([])) then bugmes();quit;end
165
 
    if or(uint32scalar <> uint32(1)) then bugmes();quit;end
166
 
    //if or(uint32rowvector <> uint32([1 -4 7])) then bugmes();quit;end
167
 
    if or(uint32rowvector <> [1 0 7]) then bugmes();quit;end
168
 
    //if or(uint32colvector <> uint32([1;-4;7])) then bugmes();quit;end
169
 
    if or(uint32colvector <> [1;0;7]) then bugmes();quit;end
170
 
    //if or(uint32matrix <> uint32([1 -4 7;-9 6 -3])) then bugmes();quit;end
171
 
    if or(uint32matrix <> [1 0 7;0 6 0]) then bugmes();quit;end
 
164
    assert_checkequal(emptyuint32matrix , uint32([]));
 
165
    assert_checkequal(uint32scalar , uint32(1));
 
166
    //assert_checkequal(uint32rowvector , uint32([1 -4 7]));
 
167
    assert_checkequal(uint32rowvector , uint32([1 0 7]));
 
168
    //assert_checkequal(uint32colvector , uint32([1;-4;7]));
 
169
    assert_checkequal(uint32colvector , uint32([1;0;7]));
 
170
    //assert_checkequal(uint32matrix , uint32([1 -4 7;-9 6 -3]));
 
171
    assert_checkequal(uint32matrix , uint32([1 0 7;0 6 0]));
172
172
    clear emptyuint32matrix uint32scalar uint32rowvector uint32colvector uint32matrix
173
173
    // TODO: uint64 tests ?
174
174
    //
175
175
    // TESTS FOR ND-ARRAYS
176
176
    //
177
 
    if or(emptyNDarray.dims <> [0 0 0]) | or(emptyNDarray.entries <> []) then bugmes();quit;end
178
 
    if or(realdoubleNDarray <> matrix(1:24, 2, 3, 4)) then bugmes();quit;end
179
 
    if or(complexdoubleNDarray <> matrix((1:24) + (1:24)*%i, 2, 3, 4)) then bugmes();quit;end
 
177
    assert_checkequal(emptyNDarray.dims , int32([0 0 0]));
 
178
    assert_checkequal(emptyNDarray.entries , []);
 
179
    assert_checkequal(realdoubleNDarray , matrix(1:24, 2, 3, 4));
 
180
    assert_checkequal(complexdoubleNDarray , matrix((1:24) + (1:24)*%i, 2, 3, 4));
180
181
    clear emptyNDarray realdoubleNDarray complexdoubleNDarray
181
182
  end
182
183
  //
183
184
  // MISC
184
185
  //
185
 
  if or(eye100x100 <> eye(100,100)) then bugmes();quit;end
 
186
  assert_checkequal(eye100x100 , eye(100,100));
186
187
end
187
188
 
188
189
 cplxdoublecolvector-v4.mat