summaryrefslogtreecommitdiff
path: root/modules/string/tests/unit_tests/length.dia.ref
blob: 1988e1609f1ab84b530cc5e0b78d8acfdd6b6393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2007-2008 - INRIA - Allan CORNET <allan.cornet@inria.fr>
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================
// <-- CLI SHELL MODE -->
// =============================================================================
// unit tests length
// =============================================================================
// = Empty matrix ==============================================================
l = length([]);
if (l <> 0) then bugmes();quit;end;
// = integer ===================================================================
N = 321;
l = length(N);
if (l <> 1) then bugmes();quit;end;
// = Matrix of integer =========================================================
N = 321;
M = 32;
PARAMIN = [N,M;M,N];
l = length(PARAMIN);
if (l <> size(PARAMIN,'*') ) then bugmes();quit;end;
// = String ====================================================================
STRING = "Scilab";
l = length(STRING);
if (l <> 6 ) then bugmes();quit;end;
// = Matrix of Strings =========================================================
STRING1 = "Scilab";
STRING2 = "Strings";
PARAMIN = [STRING1,STRING2;STRING2,STRING1];
l = length(PARAMIN);
LS1 = length(STRING1);
LS2 = length(STRING2);
if (LS1 <> 6 ) then bugmes();quit;end;
if (LS2 <> 7 ) then bugmes();quit;end;
if (l <> [ LS1, LS2; LS2 , LS1 ]) then bugmes();quit;end
// = List (of strings) =========================================================
STRING1 = "Scilab";
STRING2 = "5.x";
m=list();
m(1)=STRING1;
m(2)=STRING2;
if length(m) <> 2  then bugmes();quit;end
// = List (mixed) ==============================================================
l = list(1,["a" "b"],[1 2 3 4],%T);
if length(l) <> 4  then bugmes();quit;end
// = mlist =====================================================================
M = mlist(['V','name','value'],['a','b','c'],[1 2 3]);
if length(M) <> 3  then bugmes();quit;end
// = tlist =====================================================================
Sys=tlist(['lss';'A';'B';'C';'D';'X0';'dt'],1,2,3,4,5,'c');
if length(Sys) <> 7  then bugmes();quit;end
// = Matrix of Strings =========================================================
STRING1 = "Scilab";
STRING2 = "5.x";
LS1 = length(STRING1);
LS2 = length(STRING2);
if length([STRING1,STRING2]) <> [LS1,LS2] then bugmes();quit;end
// = Matrix of Strings =========================================================
if length('abd')<>3 then bugmes();quit;end
if length(emptystr())<>0 then bugmes();quit;end
if or(length(['abd';emptystr()])<>[3;0]) then bugmes();quit;end
if or(length(string(ones(10,10)))<>1) then bugmes();quit;end
// = with a file ===============================================================
fd = mopen(SCI+'/modules/string/tests/unit_tests/text.txt','r');
txt = mgetl( fd );
mclose( fd );
if length(txt(1)) <> 280  then bugmes();quit;end
S = size(txt);
if length(txt(S(1)-1)) <> 106  then bugmes();quit;end
if length(txt(S(1))) <> 0  then bugmes();quit;end
// = an hypermatrix (double) ===================================================
A = rand(2,5,2,3,2);
assert_checkequal(length(A), double(prod(A.dims)));
A = hypermat([2,3,4], 1:24);
assert_checkequal(length(A), double(prod(A.dims)));
// = an hypermatrix (string) ===================================================
clear S;
S(:,:,1) = ["a","b";"c","d"];
S(:,:,2) = ["ab", "bc"; "cd", "de"];
assert_checkequal(length(S),3);