blob: f8d27beeb08ed7095a0f73d859a4c0b041c81602 (
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2007-2008 - INRIA
//
// This file is distributed under the same license as the Scilab package.
// =============================================================================
// <-- CLI SHELL MODE -->
// =============================================================================
// unit tests ascii
// =============================================================================
// == TEST 1 ===================================================================
if or(ascii('abcdefghijklmnopqrstuvwxyz')<>(97:122)) then bugmes();quit;end
if or(ascii(97:122)<>'abcdefghijklmnopqrstuvwxyz') then bugmes();quit;end
if ascii('')<>[] then bugmes();quit;end
if ascii([])<>'' then bugmes();quit;end
// == TEST 2 ===================================================================
CODE_ASCII_SCILAB = [115 99 105 108 97 98];
str_scilab = 'scilab';
if ascii(str_scilab) <> CODE_ASCII_SCILAB then bugmes();quit;end
if (ascii(CODE_ASCII_SCILAB) <> str_scilab) then bugmes();quit;end
// == TEST 3 ===================================================================
if ascii([str_scilab 'a';'b' 'c']) <> [115 99 105 108 97 98 98 97 99] then bugmes();quit;end
// == TEST 4 ===================================================================
fd = mopen(SCI+'/modules/string/tests/unit_tests/text.txt','r');
txt = mgetl( fd );
mclose( fd );
ASCII_TXT = ascii(txt);
TXT_FROM_ASCII_CODE = ascii(ASCII_TXT);
if (length(TXT_FROM_ASCII_CODE) <> 27455) then bugmes();quit;end
// == TEST 5 ===================================================================
if ascii("!") <> 33 then bugmes();quit;end
if ascii("""")<> 34 then bugmes();quit;end
if ascii("#") <> 35 then bugmes();quit;end
if ascii("$") <> 36 then bugmes();quit;end
if ascii("%") <> 37 then bugmes();quit;end
if ascii("&") <> 38 then bugmes();quit;end
if ascii("''")<> 39 then bugmes();quit;end
if ascii("(") <> 40 then bugmes();quit;end
if ascii(")") <> 41 then bugmes();quit;end
if ascii("*") <> 42 then bugmes();quit;end
if ascii("+") <> 43 then bugmes();quit;end
if ascii(",") <> 44 then bugmes();quit;end
if ascii("-") <> 45 then bugmes();quit;end
if ascii(".") <> 46 then bugmes();quit;end
if ascii("/") <> 47 then bugmes();quit;end
if ascii("0") <> 48 then bugmes();quit;end
if ascii("1") <> 49 then bugmes();quit;end
if ascii("2") <> 50 then bugmes();quit;end
if ascii("3") <> 51 then bugmes();quit;end
if ascii("4") <> 52 then bugmes();quit;end
if ascii("5") <> 53 then bugmes();quit;end
if ascii("6") <> 54 then bugmes();quit;end
if ascii("7") <> 55 then bugmes();quit;end
if ascii("8") <> 56 then bugmes();quit;end
if ascii("9") <> 57 then bugmes();quit;end
if ascii(":") <> 58 then bugmes();quit;end
if ascii(";") <> 59 then bugmes();quit;end
if ascii("<") <> 60 then bugmes();quit;end
if ascii("=") <> 61 then bugmes();quit;end
if ascii(">") <> 62 then bugmes();quit;end
if ascii("?") <> 63 then bugmes();quit;end
if ascii("@") <> 64 then bugmes();quit;end
if ascii("A") <> 65 then bugmes();quit;end
if ascii("B") <> 66 then bugmes();quit;end
if ascii("C") <> 67 then bugmes();quit;end
if ascii("D") <> 68 then bugmes();quit;end
if ascii("E") <> 69 then bugmes();quit;end
if ascii("F") <> 70 then bugmes();quit;end
if ascii("G") <> 71 then bugmes();quit;end
if ascii("H") <> 72 then bugmes();quit;end
if ascii("I") <> 73 then bugmes();quit;end
if ascii("J") <> 74 then bugmes();quit;end
if ascii("K") <> 75 then bugmes();quit;end
if ascii("L") <> 76 then bugmes();quit;end
if ascii("M") <> 77 then bugmes();quit;end
if ascii("N") <> 78 then bugmes();quit;end
if ascii("O") <> 79 then bugmes();quit;end
if ascii("P") <> 80 then bugmes();quit;end
if ascii("Q") <> 81 then bugmes();quit;end
if ascii("R") <> 82 then bugmes();quit;end
if ascii("S") <> 83 then bugmes();quit;end
if ascii("T") <> 84 then bugmes();quit;end
if ascii("U") <> 85 then bugmes();quit;end
if ascii("V") <> 86 then bugmes();quit;end
if ascii("W") <> 87 then bugmes();quit;end
if ascii("X") <> 88 then bugmes();quit;end
if ascii("Y") <> 89 then bugmes();quit;end
if ascii("Z") <> 90 then bugmes();quit;end
if ascii("[") <> 91 then bugmes();quit;end
if ascii("\") <> 92 then bugmes();quit;end
if ascii("]") <> 93 then bugmes();quit;end
if ascii("^") <> 94 then bugmes();quit;end
if ascii("_") <> 95 then bugmes();quit;end
if ascii("`") <> 96 then bugmes();quit;end
if ascii("a") <> 97 then bugmes();quit;end
if ascii("b") <> 98 then bugmes();quit;end
if ascii("c") <> 99 then bugmes();quit;end
if ascii("d") <> 100 then bugmes();quit;end
if ascii("e") <> 101 then bugmes();quit;end
if ascii("f") <> 102 then bugmes();quit;end
if ascii("g") <> 103 then bugmes();quit;end
if ascii("h") <> 104 then bugmes();quit;end
if ascii("i") <> 105 then bugmes();quit;end
if ascii("j") <> 106 then bugmes();quit;end
if ascii("k") <> 107 then bugmes();quit;end
if ascii("l") <> 108 then bugmes();quit;end
if ascii("m") <> 109 then bugmes();quit;end
if ascii("n") <> 110 then bugmes();quit;end
if ascii("o") <> 111 then bugmes();quit;end
if ascii("p") <> 112 then bugmes();quit;end
if ascii("q") <> 113 then bugmes();quit;end
if ascii("r") <> 114 then bugmes();quit;end
if ascii("s") <> 115 then bugmes();quit;end
if ascii("t") <> 116 then bugmes();quit;end
if ascii("u") <> 117 then bugmes();quit;end
if ascii("v") <> 118 then bugmes();quit;end
if ascii("w") <> 119 then bugmes();quit;end
if ascii("x") <> 120 then bugmes();quit;end
if ascii("y") <> 121 then bugmes();quit;end
if ascii("z") <> 122 then bugmes();quit;end
if ascii("{") <> 123 then bugmes();quit;end
if ascii("|") <> 124 then bugmes();quit;end
if ascii("}") <> 125 then bugmes();quit;end
if ascii("~") <> 126 then bugmes();quit;end
if ascii(33) <> "!" then bugmes();quit;end
if ascii(34) <> """" then bugmes();quit;end
if ascii(35) <> "#" then bugmes();quit;end
if ascii(36) <> "$" then bugmes();quit;end
if ascii(37) <> "%" then bugmes();quit;end
if ascii(38) <> "&" then bugmes();quit;end
if ascii(39) <> "''" then bugmes();quit;end
if ascii(40) <> "(" then bugmes();quit;end
if ascii(41) <> ")" then bugmes();quit;end
if ascii(42) <> "*" then bugmes();quit;end
if ascii(43) <> "+" then bugmes();quit;end
if ascii(44) <> "," then bugmes();quit;end
if ascii(45) <> "-" then bugmes();quit;end
if ascii(46) <> "." then bugmes();quit;end
if ascii(47) <> "/" then bugmes();quit;end
if ascii(48) <> "0" then bugmes();quit;end
if ascii(49) <> "1" then bugmes();quit;end
if ascii(50) <> "2" then bugmes();quit;end
if ascii(51) <> "3" then bugmes();quit;end
if ascii(52) <> "4" then bugmes();quit;end
if ascii(53) <> "5" then bugmes();quit;end
if ascii(54) <> "6" then bugmes();quit;end
if ascii(55) <> "7" then bugmes();quit;end
if ascii(56) <> "8" then bugmes();quit;end
if ascii(57) <> "9" then bugmes();quit;end
if ascii(58) <> ":" then bugmes();quit;end
if ascii(59) <> ";" then bugmes();quit;end
if ascii(60) <> "<" then bugmes();quit;end
if ascii(61) <> "=" then bugmes();quit;end
if ascii(62) <> ">" then bugmes();quit;end
if ascii(63) <> "?" then bugmes();quit;end
if ascii(64) <> "@" then bugmes();quit;end
if ascii(65) <> "A" then bugmes();quit;end
if ascii(66) <> "B" then bugmes();quit;end
if ascii(67) <> "C" then bugmes();quit;end
if ascii(68) <> "D" then bugmes();quit;end
if ascii(69) <> "E" then bugmes();quit;end
if ascii(70) <> "F" then bugmes();quit;end
if ascii(71) <> "G" then bugmes();quit;end
if ascii(72) <> "H" then bugmes();quit;end
if ascii(73) <> "I" then bugmes();quit;end
if ascii(74) <> "J" then bugmes();quit;end
if ascii(75) <> "K" then bugmes();quit;end
if ascii(76) <> "L" then bugmes();quit;end
if ascii(77) <> "M" then bugmes();quit;end
if ascii(78) <> "N" then bugmes();quit;end
if ascii(79) <> "O" then bugmes();quit;end
if ascii(80) <> "P" then bugmes();quit;end
if ascii(81) <> "Q" then bugmes();quit;end
if ascii(82) <> "R" then bugmes();quit;end
if ascii(83) <> "S" then bugmes();quit;end
if ascii(84) <> "T" then bugmes();quit;end
if ascii(85) <> "U" then bugmes();quit;end
if ascii(86) <> "V" then bugmes();quit;end
if ascii(87) <> "W" then bugmes();quit;end
if ascii(88) <> "X" then bugmes();quit;end
if ascii(89) <> "Y" then bugmes();quit;end
if ascii(90) <> "Z" then bugmes();quit;end
if ascii(91) <> "[" then bugmes();quit;end
if ascii(92) <> "\" then bugmes();quit;end
if ascii(93) <> "]" then bugmes();quit;end
if ascii(94) <> "^" then bugmes();quit;end
if ascii(95) <> "_" then bugmes();quit;end
if ascii(96) <> "`" then bugmes();quit;end
if ascii(97) <> "a" then bugmes();quit;end
if ascii(98) <> "b" then bugmes();quit;end
if ascii(99) <> "c" then bugmes();quit;end
if ascii(100) <> "d" then bugmes();quit;end
if ascii(101) <> "e" then bugmes();quit;end
if ascii(102) <> "f" then bugmes();quit;end
if ascii(103) <> "g" then bugmes();quit;end
if ascii(104) <> "h" then bugmes();quit;end
if ascii(105) <> "i" then bugmes();quit;end
if ascii(106) <> "j" then bugmes();quit;end
if ascii(107) <> "k" then bugmes();quit;end
if ascii(108) <> "l" then bugmes();quit;end
if ascii(109) <> "m" then bugmes();quit;end
if ascii(110) <> "n" then bugmes();quit;end
if ascii(111) <> "o" then bugmes();quit;end
if ascii(112) <> "p" then bugmes();quit;end
if ascii(113) <> "q" then bugmes();quit;end
if ascii(114) <> "r" then bugmes();quit;end
if ascii(115) <> "s" then bugmes();quit;end
if ascii(116) <> "t" then bugmes();quit;end
if ascii(117) <> "u" then bugmes();quit;end
if ascii(118) <> "v" then bugmes();quit;end
if ascii(119) <> "w" then bugmes();quit;end
if ascii(120) <> "x" then bugmes();quit;end
if ascii(121) <> "y" then bugmes();quit;end
if ascii(122) <> "z" then bugmes();quit;end
if ascii(123) <> "{" then bugmes();quit;end
if ascii(124) <> "|" then bugmes();quit;end
if ascii(125) <> "}" then bugmes();quit;end
if ascii(126) <> "~" then bugmes();quit;end
// == TEST 6 ===================================================================
NB_CHARACTERS = 400000;
letters_ascii_code = ones(1,NB_CHARACTERS)*78;
letters=ascii(letters_ascii_code);
if (length(letters) <> NB_CHARACTERS) then bugmes();quit;end
// == TEST 7 ===================================================================
A = floor( 126 * rand(100,100) );
if or( ascii(A) <> ascii(int8(A)) ) then bugmes();quit;end
if or( ascii(A) <> ascii(int16(A)) ) then bugmes();quit;end
if or( ascii(A) <> ascii(int32(A)) ) then bugmes();quit;end
if or( ascii(A) <> ascii(uint8(A)) ) then bugmes();quit;end
if or( ascii(A) <> ascii(uint16(A)) ) then bugmes();quit;end
if or( ascii(A) <> ascii(uint32(A)) ) then bugmes();quit;end
|