2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 package org.scilab.tests.modules.types;
14 import org.testng.annotations.*;
16 import java.util.Arrays;
18 import org.scilab.modules.types.ScilabType;
19 import org.scilab.modules.types.ScilabDouble;
20 import org.scilab.modules.types.ScilabInteger;
21 import org.scilab.modules.types.ScilabIntegerTypeEnum;
22 import org.scilab.modules.types.ScilabBoolean;
23 import org.scilab.modules.types.ScilabString;
24 import org.scilab.modules.types.ScilabList;
25 import org.scilab.modules.types.ScilabTList;
26 import org.scilab.modules.types.ScilabMList;
27 import org.scilab.modules.types.ScilabTypeEnum;
29 public class testEquals {
32 public void compareDoubleTest() throws NullPointerException {
33 double [][]a={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
34 double [][]b={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
35 double [][]c={{42,43},{21,22}};
36 ScilabDouble aMatrix = new ScilabDouble(a);
37 ScilabDouble bMatrix = new ScilabDouble(b);
38 ScilabDouble cMatrix = new ScilabDouble(c);
39 assert aMatrix.equals(bMatrix) == true;
40 assert bMatrix.equals(aMatrix) == true;
41 assert cMatrix.equals(aMatrix) == false;
42 assert Arrays.deepEquals(aMatrix.getRealPart(), bMatrix.getRealPart()) == true;
43 assert aMatrix.toString().equals("[21.2, 22.0, 42.0, 39.0 ; 23.2, 24.0, 44.0, 40.0]") == true;
44 assert cMatrix.toString().equals("[42.0, 43.0 ; 21.0, 22.0]") == true;
45 assert aMatrix.getType() == ScilabTypeEnum.sci_matrix;
46 assert bMatrix.getType() == ScilabTypeEnum.sci_matrix;
47 assert cMatrix.getType() == ScilabTypeEnum.sci_matrix;
51 public void doubleMatrixTests() {
52 double [][]a={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
53 ScilabDouble emptyMatrix = new ScilabDouble();
54 assert emptyMatrix.getHeight() == 0;
55 assert emptyMatrix.getWidth() == 0;
56 assert emptyMatrix.isEmpty() == true;
57 assert emptyMatrix.toString().equals("[]") == true;
58 emptyMatrix.setRealPart(a);
59 emptyMatrix.setImaginaryPart(a);
60 assert emptyMatrix.getType() == ScilabTypeEnum.sci_matrix;
62 ScilabBoolean aMatrix = new ScilabBoolean(true);
63 assert aMatrix.equals(emptyMatrix) == false;
64 assert emptyMatrix.equals(aMatrix) == false;
65 assert aMatrix.getType() != ScilabTypeEnum.sci_matrix;
70 public void compareDoubleComplexTest() throws NullPointerException {
71 double [][]a={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
72 double [][]aImg={{210.2, 220.0, 420.0, 390.0},{230.2, 240.0, 440.0, 400.0}};
73 double [][]b={{21.2, 22.0, 42.0, 39.0},{23.2, 24.0, 44.0, 40.0}};
74 double [][]bImg={{210.2, 220.0, 420.0, 390.0},{230.2, 240.0, 440.0, 400.0}};
75 double [][]c={{42,43},{21,22}};
76 double [][]cImg={{420,430},{210,220}};
77 ScilabDouble aMatrix = new ScilabDouble(a, aImg);
78 ScilabDouble bMatrix = new ScilabDouble(b, bImg);
79 ScilabDouble cMatrix = new ScilabDouble(c, cImg);
80 assert aMatrix.equals(bMatrix) == true;
81 assert bMatrix.equals(aMatrix) == true;
82 assert cMatrix.equals(aMatrix) == false;
83 assert aMatrix.getType() == ScilabTypeEnum.sci_matrix;
84 assert bMatrix.getType() == ScilabTypeEnum.sci_matrix;
85 assert cMatrix.getType() == ScilabTypeEnum.sci_matrix;
87 assert Arrays.deepEquals(aMatrix.getRealPart(), bMatrix.getRealPart()) == true;
88 assert Arrays.deepEquals(aMatrix.getImaginaryPart(), bMatrix.getImaginaryPart()) == true;
89 assert aMatrix.toString().equals("[21.2 + 210.2 * %i, 22.0 + 220.0 * %i, 42.0 + 420.0 * %i, 39.0 + 390.0 * %i ; 23.2 + 230.2 * %i, 24.0 + 240.0 * %i, 44.0 + 440.0 * %i, 40.0 + 400.0 * %i]") == true;
90 assert cMatrix.toString().equals("[42.0 + 420.0 * %i, 43.0 + 430.0 * %i ; 21.0 + 210.0 * %i, 22.0 + 220.0 * %i]") == true;
92 double [] result = new double[]{21.2, 23.2, 22.0, 24.0, 42.0, 44.0, 39.0, 40.0, 210.2, 230.2, 220.0, 240.0, 420.0, 440.0, 390.0, 400.0};
93 assert aMatrix.getSerializedComplexMatrix().length == result.length;
94 assert Arrays.equals(aMatrix.getSerializedComplexMatrix(),result) == true;
95 ScilabDouble scalarComplex = new ScilabDouble(1,2);
96 assert aMatrix.equals(scalarComplex) == false;
97 assert aMatrix.equals(bMatrix) == true;
102 public void compareInteger8Test() throws NullPointerException {
103 byte [][]a={{32,42,41}, {12,13,32}};
104 byte [][]b={{32,42,41}, {12,13,32}};
105 byte [][]c={{42,43},{21,22}};
106 ScilabInteger aMatrix = new ScilabInteger(a, true);
107 ScilabInteger bMatrix = new ScilabInteger(b, true);
108 ScilabInteger cMatrix = new ScilabInteger(c, true);
109 ScilabInteger dMatrix = new ScilabInteger(c, false);
110 assert aMatrix.equals(bMatrix) == true;
111 assert bMatrix.equals(aMatrix) == true;
112 assert cMatrix.equals(aMatrix) == false;
113 assert cMatrix.equals(dMatrix) == true;
114 assert aMatrix.getType() == ScilabTypeEnum.sci_ints;
115 assert bMatrix.getType() == ScilabTypeEnum.sci_ints;
116 assert cMatrix.getType() == ScilabTypeEnum.sci_ints;
118 assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
119 assert aMatrix.toString().equals("uint8([32, 42, 41 ; 12, 13, 32])") == true;
120 assert cMatrix.toString().equals("uint8([42, 43 ; 21, 22])") == true;
121 assert dMatrix.toString().equals("int8([42, 43 ; 21, 22])") == true;
122 assert aMatrix.getDataAsByte().length == a.length;
123 assert aMatrix.getDataAsByte()[0].length == a[0].length;
124 byte [][]d = aMatrix.getDataAsByte();
125 long [][]d2 = aMatrix.getData();
126 assert d[0][0] == 32;
127 assert d2[0][0] == 32;
128 assert Arrays.deepEquals(a,d);
129 assert aMatrix.getPrec() == ScilabIntegerTypeEnum.sci_uint8;
130 assert dMatrix.getPrec() == ScilabIntegerTypeEnum.sci_int8;
131 assert aMatrix.isUnsigned() == true;
132 assert dMatrix.isUnsigned() == false;
133 assert ScilabInteger.convertOldType("TYPE8", true) == ScilabIntegerTypeEnum.sci_uint8;
134 assert ScilabInteger.convertOldType("TYPE8", false) == ScilabIntegerTypeEnum.sci_int8;
139 public void integer8MatrixTests() {
140 byte [][]a={{21, 22, 42, 39},{23, 24, 44, 40}};
141 ScilabInteger emptyMatrix = new ScilabInteger();
142 assert emptyMatrix.getHeight() == 0;
143 assert emptyMatrix.getWidth() == 0;
144 assert emptyMatrix.isEmpty() == true;
145 assert emptyMatrix.toString().equals("int([])") == true;
146 assert emptyMatrix.getType() == ScilabTypeEnum.sci_ints;
147 emptyMatrix.setData(a, true);
148 assert emptyMatrix.getType() == ScilabTypeEnum.sci_ints;
150 ScilabBoolean aMatrix = new ScilabBoolean(true);
151 assert aMatrix.equals(emptyMatrix) == false;
152 assert emptyMatrix.equals(aMatrix) == false;
153 ScilabInteger scalarInteger = new ScilabInteger((byte)2);
158 public void compareInteger16Test() throws NullPointerException {
159 short [][]a={{32,42,41}, {12,13,32}};
160 short [][]b={{32,42,41}, {12,13,32}};
161 short [][]c={{42,43},{21,22}};
162 ScilabInteger aMatrix = new ScilabInteger(a, true);
163 ScilabInteger bMatrix = new ScilabInteger(b, true);
164 ScilabInteger cMatrix = new ScilabInteger(c, true);
165 ScilabInteger dMatrix = new ScilabInteger(c, false);
166 assert aMatrix.equals(bMatrix) == true;
167 assert bMatrix.equals(aMatrix) == true;
168 assert cMatrix.equals(aMatrix) == false;
169 assert cMatrix.equals(dMatrix) == true;
170 assert aMatrix.getType() == ScilabTypeEnum.sci_ints;
171 assert bMatrix.getType() == ScilabTypeEnum.sci_ints;
172 assert cMatrix.getType() == ScilabTypeEnum.sci_ints;
174 assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
175 assert aMatrix.toString().equals("uint16([32, 42, 41 ; 12, 13, 32])") == true;
176 assert cMatrix.toString().equals("uint16([42, 43 ; 21, 22])") == true;
177 assert dMatrix.toString().equals("int16([42, 43 ; 21, 22])") == true;
178 assert aMatrix.getDataAsShort().length == a.length;
179 assert aMatrix.getDataAsShort()[0].length == a[0].length;
180 short [][]d = aMatrix.getDataAsShort();
181 long [][]d2 = aMatrix.getData();
182 assert d[0][0] == 32;
183 assert d2[0][0] == 32;
184 assert Arrays.deepEquals(a,d);
185 assert aMatrix.getPrec() == ScilabIntegerTypeEnum.sci_uint16;
186 assert dMatrix.getPrec() == ScilabIntegerTypeEnum.sci_int16;
187 assert aMatrix.isUnsigned() == true;
188 assert dMatrix.isUnsigned() == false;
189 assert ScilabInteger.convertOldType("TYPE16", true) == ScilabIntegerTypeEnum.sci_uint16;
190 assert ScilabInteger.convertOldType("TYPE16", false) == ScilabIntegerTypeEnum.sci_int16;
194 public void integer16MatrixTests() {
195 short [][]a={{21, 22, 42, 39},{23, 24, 44, 40}};
196 ScilabInteger emptyMatrix = new ScilabInteger();
197 assert emptyMatrix.getType() == ScilabTypeEnum.sci_ints;
198 emptyMatrix.setData(a, true);
199 assert emptyMatrix.getType() == ScilabTypeEnum.sci_ints;
201 ScilabBoolean aMatrix = new ScilabBoolean(true);
202 assert aMatrix.equals(emptyMatrix) == false;
203 assert emptyMatrix.equals(aMatrix) == false;
204 ScilabInteger scalarInteger = new ScilabInteger((short)2);
208 public void compareInteger32Test() throws NullPointerException {
209 int [][]a={{32,42,41}, {12,13,32}};
210 int [][]b={{32,42,41}, {12,13,32}};
211 int [][]c={{42,43},{21,22}};
212 ScilabInteger aMatrix = new ScilabInteger(a, true);
213 ScilabInteger bMatrix = new ScilabInteger(b, true);
214 ScilabInteger cMatrix = new ScilabInteger(c, true);
215 ScilabInteger dMatrix = new ScilabInteger(c, false);
216 assert aMatrix.equals(bMatrix) == true;
217 assert bMatrix.equals(aMatrix) == true;
218 assert cMatrix.equals(aMatrix) == false;
219 assert cMatrix.equals(dMatrix) == true;
220 assert aMatrix.getType() == ScilabTypeEnum.sci_ints;
221 assert bMatrix.getType() == ScilabTypeEnum.sci_ints;
222 assert cMatrix.getType() == ScilabTypeEnum.sci_ints;
224 assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
225 assert aMatrix.toString().equals("uint32([32, 42, 41 ; 12, 13, 32])") == true;
226 assert cMatrix.toString().equals("uint32([42, 43 ; 21, 22])") == true;
227 assert dMatrix.toString().equals("int32([42, 43 ; 21, 22])") == true;
228 assert aMatrix.getDataAsInt().length == a.length;
229 assert aMatrix.getDataAsInt()[0].length == a[0].length;
230 int [][]d = aMatrix.getDataAsInt();
231 long [][]d2 = aMatrix.getData();
232 assert d[0][0] == 32;
233 assert d2[0][0] == 32;
234 assert Arrays.deepEquals(a,d);
235 assert aMatrix.getPrec() == ScilabIntegerTypeEnum.sci_uint32;
236 assert dMatrix.getPrec() == ScilabIntegerTypeEnum.sci_int32;
237 assert aMatrix.isUnsigned() == true;
238 assert dMatrix.isUnsigned() == false;
239 assert ScilabInteger.convertOldType("TYPE32", true) == ScilabIntegerTypeEnum.sci_uint32;
240 assert ScilabInteger.convertOldType("TYPE32", false) == ScilabIntegerTypeEnum.sci_int32;
244 public void integer32MatrixTests() {
245 int [][]a={{21, 22, 42, 39},{23, 24, 44, 40}};
246 ScilabInteger emptyMatrix = new ScilabInteger();
247 assert emptyMatrix.getType() == ScilabTypeEnum.sci_ints;
248 emptyMatrix.setData(a, true);
249 assert emptyMatrix.getType() == ScilabTypeEnum.sci_ints;
251 ScilabBoolean aMatrix = new ScilabBoolean(true);
252 assert aMatrix.equals(emptyMatrix) == false;
253 assert emptyMatrix.equals(aMatrix) == false;
254 ScilabInteger scalarInteger = new ScilabInteger((int)2);
258 public void compareInteger64Test() throws NullPointerException {
259 long [][]a={{32,42,41}, {12,13,32}};
260 long [][]b={{32,42,41}, {12,13,32}};
261 long [][]c={{42,43},{21,22}};
262 ScilabInteger aMatrix = new ScilabInteger(a, true);
263 ScilabInteger bMatrix = new ScilabInteger(b, true);
264 ScilabInteger cMatrix = new ScilabInteger(c, true);
265 ScilabInteger dMatrix = new ScilabInteger(c, false);
266 assert aMatrix.equals(bMatrix) == true;
267 assert bMatrix.equals(aMatrix) == true;
268 assert cMatrix.equals(aMatrix) == false;
269 assert cMatrix.equals(dMatrix) == true;
270 assert aMatrix.getType() == ScilabTypeEnum.sci_ints;
271 assert bMatrix.getType() == ScilabTypeEnum.sci_ints;
272 assert cMatrix.getType() == ScilabTypeEnum.sci_ints;
274 assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
275 assert aMatrix.toString().equals("uint64([32, 42, 41 ; 12, 13, 32])") == true;
276 assert cMatrix.toString().equals("uint64([42, 43 ; 21, 22])") == true;
277 assert dMatrix.toString().equals("int64([42, 43 ; 21, 22])") == true;
278 assert aMatrix.getDataAsLong().length == a.length;
279 assert aMatrix.getDataAsLong()[0].length == a[0].length;
280 long [][]d = aMatrix.getDataAsLong();
281 long [][]d2 = aMatrix.getData();
282 assert d[0][0] == 32;
283 assert d2[0][0] == 32;
284 assert Arrays.deepEquals(a,d);
285 assert aMatrix.getPrec() == ScilabIntegerTypeEnum.sci_uint64;
286 assert dMatrix.getPrec() == ScilabIntegerTypeEnum.sci_int64;
287 assert aMatrix.isUnsigned() == true;
288 assert dMatrix.isUnsigned() == false;
289 assert ScilabInteger.convertOldType("TYPE64", true) == ScilabIntegerTypeEnum.sci_uint64;
290 assert ScilabInteger.convertOldType("TYPE64", false) == ScilabIntegerTypeEnum.sci_int64;
294 public void integer64MatrixTests() {
295 long [][]a={{21, 22, 42, 39},{23, 24, 44, 40}};
296 ScilabInteger emptyMatrix = new ScilabInteger();
297 assert emptyMatrix.getType() == ScilabTypeEnum.sci_ints;
298 emptyMatrix.setData(a, true);
299 assert emptyMatrix.getType() == ScilabTypeEnum.sci_ints;
301 ScilabBoolean aMatrix = new ScilabBoolean(true);
302 assert aMatrix.equals(emptyMatrix) == false;
303 assert emptyMatrix.equals(aMatrix) == false;
304 ScilabInteger scalarInteger = new ScilabInteger((long)2);
309 public void compareBooleanTest() throws NullPointerException {
310 boolean [][]a={{true,false,true}, {true,true,true}};
311 boolean [][]b={{true,false,true}, {true,true,true}};
312 boolean [][]c={{true,false},{false,true}};
313 ScilabBoolean aMatrix = new ScilabBoolean(a);
314 ScilabBoolean bMatrix = new ScilabBoolean(b);
315 ScilabBoolean cMatrix = new ScilabBoolean(c);
316 assert aMatrix.equals(bMatrix) == true;
317 assert bMatrix.equals(aMatrix) == true;
318 assert cMatrix.equals(aMatrix) == false;
319 assert aMatrix.getType() == ScilabTypeEnum.sci_boolean;
320 assert bMatrix.getType() == ScilabTypeEnum.sci_boolean;
321 assert cMatrix.getType() == ScilabTypeEnum.sci_boolean;
323 assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
324 assert aMatrix.toString().equals("[%t, %f, %t ; %t, %t, %t]") == true;
325 assert cMatrix.toString().equals("[%t, %f ; %f, %t]") == true;
329 public void booleanMatrixTests() {
330 boolean [][]a={{true,false,true}, {true,true,true}};
331 ScilabBoolean emptyMatrix = new ScilabBoolean();
332 assert emptyMatrix.getHeight() == 0;
333 assert emptyMatrix.getWidth() == 0;
334 assert emptyMatrix.isEmpty() == true;
335 assert emptyMatrix.toString().equals("[]") == true;
336 assert emptyMatrix.getType() == ScilabTypeEnum.sci_boolean;
337 emptyMatrix.setData(a);
338 assert emptyMatrix.getType() == ScilabTypeEnum.sci_boolean;
340 ScilabDouble aMatrix = new ScilabDouble(2);
341 assert aMatrix.equals(emptyMatrix) == false;
342 assert emptyMatrix.equals(aMatrix) == false;
346 public void compareStringTest() throws NullPointerException {
347 String [][]a={{"This","is","my","string"},{"and","I want to", "compare"," them"}};
348 String [][]b={{"This","is","my","string"},{"and","I want to", "compare"," them"}};
349 String [][]c={{"Wrong","string"},{"right","string"}};
350 ScilabString aMatrix = new ScilabString(a);
351 ScilabString bMatrix = new ScilabString(b);
352 ScilabString cMatrix = new ScilabString(c);
353 assert aMatrix.equals(bMatrix) == true;
354 assert bMatrix.equals(aMatrix) == true;
355 assert cMatrix.equals(aMatrix) == false;
356 assert aMatrix.getType() == ScilabTypeEnum.sci_strings;
357 assert bMatrix.getType() == ScilabTypeEnum.sci_strings;
358 assert cMatrix.getType() == ScilabTypeEnum.sci_strings;
360 assert Arrays.deepEquals(aMatrix.getData(), bMatrix.getData()) == true;
361 assert aMatrix.toString().equals("[\"This\", \"is\", \"my\", \"string\" ; \"and\", \"I want to\", \"compare\", \" them\"]") == true;
362 assert cMatrix.toString().equals("[\"Wrong\", \"string\" ; \"right\", \"string\"]") == true;
366 @Test(expectedExceptions = IllegalArgumentException.class)
367 public void stringMatrixTests() {
368 String [][]a={{"This","is","my","string"},{"and","I want to", "compare"," them"}};
369 ScilabString emptyMatrix = new ScilabString();
370 assert emptyMatrix.getHeight() == 0;
371 assert emptyMatrix.getWidth() == 0;
372 assert emptyMatrix.isEmpty() == true;
373 assert emptyMatrix.toString().equals("[]") == true;
374 assert emptyMatrix.getType() == ScilabTypeEnum.sci_strings;
375 emptyMatrix.setData(a);
376 assert emptyMatrix.getType() == ScilabTypeEnum.sci_strings;
377 ScilabDouble aMatrix = new ScilabDouble(2);
378 assert aMatrix.equals(emptyMatrix) == false;
379 assert emptyMatrix.equals(aMatrix) == false;
380 String []b={"This","is","my","string"};
381 ScilabString vectorString = new ScilabString(b);
383 ScilabString emptyString = new ScilabString(c);
384 ScilabString nullString = new ScilabString((String)null);
389 public void compareListTest() throws NullPointerException {
390 ScilabList data = new ScilabList();
391 assert data.getType() == ScilabTypeEnum.sci_list;
392 assert data.getHeight() == 0;
393 assert data.getWidth() == 0;
394 assert data.toString().equals("list()");
395 data.add(new ScilabDouble(2));
396 assert data.getHeight() == 1;
397 assert data.getWidth() == 1;
398 data.add(new ScilabDouble(51));
399 assert data.getHeight() == 1;
400 assert data.getWidth() == 2;
401 data.add(new ScilabString("hello"));
402 ScilabList data2 = new ScilabList();
403 data2.add(new ScilabDouble(2));
404 data2.add(new ScilabDouble(51));
405 data2.add(new ScilabString("hello"));
406 ScilabList data3 = new ScilabList();
407 data3.add(new ScilabDouble(2));
408 data3.add(new ScilabDouble(42));
409 data3.add(new ScilabBoolean(true));
410 data3.add(new ScilabString("hello"));
411 assert data.equals(data2) == true;
412 assert data.equals(data3) == false;
413 assert data.toString().equals("list([2.0], [51.0], [\"hello\"])") == true;
414 assert data3.toString().equals("list([2.0], [42.0], [%t], [\"hello\"])") == true;
416 ScilabList data4 = new ScilabList(data3);
417 assert data4.equals(data3) == true;
418 assert data4.getType() == ScilabTypeEnum.sci_list;
424 public void compareTListTest() throws NullPointerException {
425 ScilabTList data = new ScilabTList();
426 assert data.getType() == ScilabTypeEnum.sci_tlist;
427 assert data.getHeight() == 0;
428 assert data.getWidth() == 0;
429 assert data.toString().equals("tlist()");
430 data.add(new ScilabString("hello"));
431 assert data.getHeight() == 1;
432 assert data.getWidth() == 1;
433 data.add(new ScilabDouble(2));
434 assert data.getHeight() == 1;
435 assert data.getWidth() == 2;
436 data.add(new ScilabDouble(51));
437 assert data.getHeight() == 1;
438 assert data.getWidth() == 3;
439 ScilabTList data2 = new ScilabTList();
440 data2.add(new ScilabString("hello"));
441 data2.add(new ScilabDouble(2));
442 data2.add(new ScilabDouble(51));
443 ScilabTList data3 = new ScilabTList();
444 data3.add(new ScilabString("hello"));
445 data3.add(new ScilabDouble(2));
446 data3.add(new ScilabDouble(42));
447 data3.add(new ScilabBoolean(true));
448 assert data.equals(data2) == true;
449 assert data.equals(data3) == false;
451 assert data.toString().equals("tlist([\"hello\"], [2.0], [51.0])") == true;
452 assert data3.toString().equals("tlist([\"hello\"], [2.0], [42.0], [%t])") == true;
453 String []b={"a","b","c"};
455 ScilabTList tlist = new ScilabTList(b);
456 tlist.add(new ScilabDouble(2));
457 tlist.add(new ScilabDouble(3));
458 assert tlist.toString().equals("tlist([\"a\", \"b\", \"c\"], [2.0], [3.0])") == true;
459 ScilabTList tlistFromAnOther = new ScilabTList(b, data2);
460 assert tlistFromAnOther.getHeight() == 1;
461 assert tlistFromAnOther.getWidth() == 4;
462 assert tlistFromAnOther.toString().equals("tlist([\"a\", \"b\", \"c\"], [\"hello\"], [2.0], [51.0])");
463 assert tlist.getType() == ScilabTypeEnum.sci_tlist;
468 public void compareMListTest() throws NullPointerException {
469 ScilabMList data = new ScilabMList();
470 assert data.getType() == ScilabTypeEnum.sci_mlist;
471 assert data.getHeight() == 0;
472 assert data.getWidth() == 0;
473 assert data.toString().equals("mlist()");
474 data.add(new ScilabString("hello"));
475 assert data.getHeight() == 1;
476 assert data.getWidth() == 1;
477 data.add(new ScilabDouble(2));
478 assert data.getHeight() == 1;
479 assert data.getWidth() == 2;
480 data.add(new ScilabDouble(51));
481 assert data.getHeight() == 1;
482 assert data.getWidth() == 3;
483 ScilabMList data2 = new ScilabMList();
484 data2.add(new ScilabString("hello"));
485 data2.add(new ScilabDouble(2));
486 data2.add(new ScilabDouble(51));
487 ScilabMList data3 = new ScilabMList();
488 data3.add(new ScilabString("hello"));
489 data3.add(new ScilabDouble(2));
490 data3.add(new ScilabDouble(42));
491 data3.add(new ScilabBoolean(true));
492 assert data3.getType() == ScilabTypeEnum.sci_mlist;
493 assert data.equals(data2) == true;
494 assert data.equals(data3) == false;
495 assert data.toString().equals("mlist([\"hello\"], [2.0], [51.0])") == true;
496 assert data3.toString().equals("mlist([\"hello\"], [2.0], [42.0], [%t])") == true;
497 String []b={"a","b","c"};
499 ScilabMList mlist = new ScilabMList(b);
500 mlist.add(new ScilabDouble(2));
501 mlist.add(new ScilabDouble(3));
502 assert mlist.toString().equals("mlist([\"a\", \"b\", \"c\"], [2.0], [3.0])") == true;
503 ScilabMList mlistFromAnOther = new ScilabMList(b, data2);
504 assert mlistFromAnOther.getHeight() == 1;
505 assert mlistFromAnOther.getWidth() == 4;
506 assert mlistFromAnOther.toString().equals("mlist([\"a\", \"b\", \"c\"], [\"hello\"], [2.0], [51.0])");