1 /******************************************************************************
2 * Copyright (c) 2000-2014 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8 // This module tests the following functions for UTF-32:
12 module UTF32Testcases {
14 import from Common all;
16 //=========================================================================
18 //=========================================================================
20 // Insert test cases here if applicable!
21 // You can use the test_case skeleton!
23 testcase tc_converter_test_temp() runs on MTC {
24 var octetstring o := '010203040a0b0c0d'O
28 if(o=='040302010d0c0b0a'O){
36 //==== The next 4 testcase groups uses the Uncode standard 5.0 / Chapter 3/ Table 3-9 ======
39 testcase tc_oct2unichar_UTF32_1() runs on MTC {
40 var octetstring o := c_BOM_UTF32BE & '0000004D'O
41 var universal charstring u_expected := char(0,0,0,77);
43 f_oct2unichar_positivetest(
46 expectedUCS:= u_expected,
47 expectedEncType:="UTF-32BE",
52 testcase tc_oct2unichar_UTF32BE_1() runs on MTC {
53 var octetstring o := c_BOM_UTF32BE & '0000004D'O
54 var universal charstring u_expected := char(0,0,0,77);
57 f_oct2unichar_positivetest(
60 expectedUCS:= u_expected,
61 expectedEncType:="UTF-32BE",
66 testcase tc_oct2unichar_UTF32LE_1() runs on MTC {
67 var octetstring o := c_BOM_UTF32BE & '0000004D'O
68 var universal charstring u_expected := char(0,0,0,77);
70 f_changeOrderUTF32(o);
72 f_oct2unichar_positivetest(
75 expectedUCS:= u_expected,
76 expectedEncType:="UTF-32LE",
82 testcase tc_oct2unichar_UTF32_2() runs on MTC {
83 var octetstring o := c_BOM_UTF32BE & '00000430'O
84 var universal charstring u_expected := char(0,0,4,48);
86 f_oct2unichar_positivetest(
89 expectedUCS:= u_expected,
90 expectedEncType:="UTF-32BE",
95 testcase tc_oct2unichar_UTF32BE_2() runs on MTC {
96 var octetstring o := c_BOM_UTF32BE & '00000430'O
97 var universal charstring u_expected := char(0,0,4,48);
100 f_oct2unichar_positivetest(
103 expectedUCS:= u_expected,
104 expectedEncType:="UTF-32BE",
111 testcase tc_oct2unichar_UTF32LE_2() runs on MTC {
112 var octetstring o := c_BOM_UTF32BE & '00000430'O
113 var universal charstring u_expected := char(0,0,4,48);
115 f_changeOrderUTF32(o);
117 f_oct2unichar_positivetest(
120 expectedUCS:= u_expected,
121 expectedEncType:="UTF-32LE",
127 testcase tc_oct2unichar_UTF32_3() runs on MTC {
128 var octetstring o := c_BOM_UTF32BE & '00004E8C'O
129 var universal charstring u_expected := char(0,0,78,140);
131 f_oct2unichar_positivetest(
134 expectedUCS:= u_expected,
135 expectedEncType:="UTF-32BE",
140 testcase tc_oct2unichar_UTF32BE_3() runs on MTC {
141 var octetstring o := c_BOM_UTF32BE & '00004E8C'O
142 var universal charstring u_expected := char(0,0,78,140);
145 f_oct2unichar_positivetest(
148 expectedUCS:= u_expected,
149 expectedEncType:="UTF-32BE",
154 testcase tc_oct2unichar_UTF32LE_3() runs on MTC {
155 var octetstring o := c_BOM_UTF32BE & '00004E8C'O
156 var universal charstring u_expected := char(0,0,78,140);
158 f_changeOrderUTF32(o);
160 f_oct2unichar_positivetest(
163 expectedUCS:= u_expected,
164 expectedEncType:="UTF-32LE",
171 testcase tc_oct2unichar_UTF32_4() runs on MTC {
172 var octetstring o := c_BOM_UTF32BE & '00010302'O
173 var universal charstring u_expected := char(0,1,3,2);
175 f_oct2unichar_positivetest(
178 expectedUCS:=char(0,1,3,2),
179 expectedEncType:="UTF-32BE",
184 testcase tc_oct2unichar_UTF32BE_4() runs on MTC {
185 var octetstring o := c_BOM_UTF32BE & '00010302'O
186 var universal charstring u_expected := char(0,1,3,2);
189 f_oct2unichar_positivetest(
192 expectedUCS:=char(0,1,3,2),
193 expectedEncType:="UTF-32BE",
200 testcase tc_oct2unichar_UTF32LE_4() runs on MTC {
201 var octetstring o := c_BOM_UTF32BE & '00010302'O
203 var universal charstring u_expected := char(0,1,3,2);
205 f_changeOrderUTF32(o);
207 f_oct2unichar_positivetest(
210 expectedUCS:=char(0,1,3,2),
211 expectedEncType:="UTF-32LE",
216 testcase tc_oct2unichar_UTF32_4_negative() runs on MTC {
217 var octetstring o := c_BOM_UTF32BE & '00010302'O
218 var universal charstring u_expected := char(0,1,3,2);
220 f_changeOrderUTF32(o);
222 f_oct2unichar_negativetest(
225 expectedErrorMsg:="Any UTF-32 code \(0xFFFE0000\) greater than 0x0010FFFF is ill-formed"
229 testcase tc_oct2unichar_UTF32BE_4_negative() runs on MTC {
230 var octetstring o := c_BOM_UTF32BE & '00010302'O
231 var universal charstring u_expected := char(0,1,3,2);
233 f_changeOrderUTF32(o);
235 f_oct2unichar_negativetest(
238 expectedErrorMsg:="Any UTF-32 code \(0xFFFE0000\) greater than 0x0010FFFF is ill-formed"
242 testcase tc_oct2unichar_UTF32LE_4_negative() runs on MTC {
243 var octetstring o := c_BOM_UTF32BE & '00010302'O
244 var universal charstring u_expected := char(0,1,3,2);
246 f_oct2unichar_negativetest(
249 expectedErrorMsg:="Any UTF-32 code \(0xFFFE0000\) greater than 0x0010FFFF is ill-formed"
254 // ==== General test ===
256 testcase tc_oct2unichar_UTF32BE_BMP_low() runs on MTC {
259 var integer N := oct2int('D7FF'O)
261 for(var integer i:=L;i<=N;i:=i+2049) {
263 for(var integer j:=0;j<4;j:=j+1) {
264 f_oct2unichar_positivetest(
265 inputOs := c_BOM_UTF32BE & int2oct(i+j,4),
266 encType := "UTF-32BE",
267 expectedUCS := int2unichar(i+j),
268 expectedEncType := "UTF-32BE"
275 testcase tc_oct2unichar_UTF32BE_BMP_hi() runs on MTC {
277 var integer L := oct2int('E000'O)
278 var integer N := oct2int('FFFF'O)
280 for(var integer i:=L;i<=N;i:=i+2049) {
282 for(var integer j:=0;j<4;j:=j+1) {
283 log(">>=====i: ",i," j: ",j,"=======")
284 f_oct2unichar_positivetest(
285 inputOs := c_BOM_UTF32BE & int2oct(i+j,4),
286 encType := "UTF-32BE",
287 expectedUCS := int2unichar(i+j),
288 expectedEncType := "UTF-32BE"
295 testcase tc_oct2unichar_UTF32LE_BMP_low() runs on MTC {
298 var integer N := oct2int('D7FF'O)
301 for(var integer i:=L;i<=N;i:=i+2049) {
303 for(var integer j:=0;j<4;j:=j+1) {
304 o:=c_BOM_UTF32BE & int2oct(i+j,4);
305 f_changeOrderUTF32(o);
306 f_oct2unichar_positivetest(
308 encType := "UTF-32LE",
309 expectedUCS := int2unichar(i+j),
310 expectedEncType := "UTF-32LE"
317 testcase tc_oct2unichar_UTF32LE_BMP_hi() runs on MTC {
319 var integer L := oct2int('E000'O)
320 var integer N := oct2int('FFFF'O)
323 for(var integer i:=L;i<=N;i:=i+2049) {
324 for(var integer j:=0;j<4;j:=j+1) {
325 o:=c_BOM_UTF32BE & int2oct(i+j,4);
326 f_changeOrderUTF32(o);
327 f_oct2unichar_positivetest(
329 encType := "UTF-32LE",
330 expectedUCS := int2unichar(i+j),
331 expectedEncType := "UTF-32LE"
338 //=== higher planes ====
340 testcase tc_oct2unichar_UTF32() runs on MTC {
342 var integer L := oct2int('010000'O);
343 var integer N := oct2int('10FFFF'O)
345 for(var integer i:=L;i<=N;i:=i+25007) {
347 for(var integer j:=0;j<4;j:=j+1) {
348 log("=====i: ",i," j: ",j,"=======")
349 f_oct2unichar_positivetest(
350 inputOs := c_BOM_UTF32BE & int2oct(i+j,4),
352 expectedUCS := int2unichar(i+j),
353 expectedEncType := "UTF-32BE"
360 testcase tc_oct2unichar_UTF32BE() runs on MTC {
362 var integer L := oct2int('010000'O);
363 var integer N := oct2int('10FFFF'O)
365 for(var integer i:=L;i<=N;i:=i+256*64) {
367 for(var integer j:=0;j<4;j:=j+1) {
368 f_oct2unichar_positivetest(
369 inputOs := c_BOM_UTF32BE & int2oct(i+j,4),
370 encType := "UTF-32BE",
371 expectedUCS := int2unichar(i+j),
372 expectedEncType := "UTF-32BE"
380 testcase tc_oct2unichar_UTF32LE() runs on MTC {
382 var integer L := oct2int('010000'O);
383 var integer N := oct2int('10FFFF'O)
386 for(var integer i:=L;i<=N;i:=i+256*64) {
388 for(var integer j:=0;j<4;j:=j+1) {
389 o:=c_BOM_UTF32BE & int2oct(i+j,4);
390 f_changeOrderUTF32(o);
391 f_oct2unichar_positivetest(
393 encType := "UTF-32LE",
394 expectedUCS := int2unichar(i+j),
395 expectedEncType := "UTF-32LE"
402 testcase tc_unichar2oct_utf32_asciistring() runs on MTC {
403 var universal charstring us1 := c_arvizturo; //"Árvíztűrő tükörfúrógép"
404 var universal charstring us2 :="Steve Jobs likes the Apple"
406 var octetstring os_expected := f_ucharstring2utf32BE(us1);
408 f_unichar2oct_positivetest(
410 encodingType:="UTF-32",
411 expectedResult := os_expected
414 os_expected := f_ucharstring2utf32BE(us2);
416 f_unichar2oct_positivetest(
418 encodingType:="UTF-32",
419 expectedResult := os_expected
426 testcase tc_unichar2oct_utf32BE_asciistring() runs on MTC {
428 var universal charstring us1 := c_arvizturo; //"Árvíztűrő tükörfúrógép"
429 var universal charstring us2 :="Steve Jobs likes the Apple"
431 var octetstring os_expected := f_ucharstring2utf32BE(us1);
433 f_unichar2oct_positivetest(
435 encodingType:="UTF-32BE",
436 expectedResult := os_expected
439 os_expected := f_ucharstring2utf32BE(us2);
441 f_unichar2oct_positivetest(
443 encodingType:="UTF-32BE",
444 expectedResult := os_expected
450 testcase tc_unichar2oct_utf32LE_asciistring() runs on MTC {
452 var universal charstring us1 := c_arvizturo; //"Árvíztűrő tükörfúrógép"
453 var universal charstring us2 :="Steve Jobs likes the Apple"
455 var octetstring os_expected := f_ucharstring2utf32BE(us1);
456 if( not f_changeOrderUTF32(os_expected) ) { setverdict(fail, "Odd length is not expected") }
457 f_unichar2oct_positivetest(
459 encodingType:="UTF-32LE",
460 expectedResult := os_expected
463 os_expected := f_ucharstring2utf32BE(us2);
464 if( not f_changeOrderUTF32(os_expected) ) { setverdict(fail, "Odd length is not expected") }
465 f_unichar2oct_positivetest(
467 encodingType:="UTF-32LE",
468 expectedResult := os_expected
474 testcase tc_unichar2oct_utf32_upperplane_longer() runs on MTC {
476 char(0,1,0,0) & char(0,1,0,175) & char(0,1,255,255),
477 char(0,2,0,0) & char(0,2,0,175) & char(0,2,255,255),
478 char(0,3,0,0) & char(0,3,0,175) & char(0,3,255,255),
479 char(0,15,0,0)& char(0,15,0,175)& char(0,15,255,255),
480 char(0,16,0,0)& char(0,16,0,175)& char(0,16,255,255),
481 char(0,16,0,0) & char(0,0,0,1) & " "
483 var octetstring os_expected;
484 var integer len:=lengthof(us);
486 for(var integer i:=0;i<len;i:=i+1) {
487 os_expected := f_ucharstring2utf32BE(us[i]);
488 f_unichar2oct_positivetest(
490 encodingType:="UTF-32",
491 expectedResult := os_expected
496 testcase tc_unichar2oct_utf32BE_upperplane_longer() runs on MTC {
498 char(0,1,0,0) & char(0,1,0,175) & char(0,1,255,255),
499 char(0,2,0,0) & char(0,2,0,175) & char(0,2,255,255),
500 char(0,3,0,0) & char(0,3,0,175) & char(0,3,255,255),
501 char(0,15,0,0)& char(0,15,0,175)& char(0,15,255,255),
502 char(0,16,0,0)& char(0,16,0,175)& char(0,16,255,255),
503 char(0,16,0,0) & char(0,0,0,1) & " "
505 var octetstring os_expected;
506 var integer len:=lengthof(us);
508 for(var integer i:=0;i<len;i:=i+1) {
509 os_expected := f_ucharstring2utf32BE(us[i]);
510 f_unichar2oct_positivetest(
512 encodingType:="UTF-32BE",
513 expectedResult := os_expected
518 testcase tc_unichar2oct_utf32LE_upperplane_longer() runs on MTC {
520 char(0,1,0,0) & char(0,1,0,175) & char(0,1,255,255),
521 char(0,2,0,0) & char(0,2,0,175) & char(0,2,255,255),
522 char(0,3,0,0) & char(0,3,0,175) & char(0,3,255,255),
523 char(0,15,0,0)& char(0,15,0,175)& char(0,15,255,255),
524 char(0,16,0,0)& char(0,16,0,175)& char(0,16,255,255),
525 char(0,16,0,0) & char(0,0,0,1) & " "
527 var octetstring os_expected;
528 var integer len:=lengthof(us);
530 for(var integer i:=0;i<len;i:=i+1) {
531 os_expected := f_ucharstring2utf32BE(us[i]);
532 if( not f_changeOrderUTF32(os_expected) ) { setverdict(fail, "Odd length is not expected") }
533 f_unichar2oct_positivetest(
535 encodingType:="UTF-32LE",
536 expectedResult := os_expected
540 //=========================================================================
542 //=========================================================================
545 execute(tc_converter_test_temp())
546 execute(tc_oct2unichar_UTF32_1());
547 execute(tc_oct2unichar_UTF32BE_1());
548 execute(tc_oct2unichar_UTF32LE_1());
549 execute(tc_oct2unichar_UTF32_2());
550 execute(tc_oct2unichar_UTF32BE_2());
551 execute(tc_oct2unichar_UTF32LE_2());
552 execute(tc_oct2unichar_UTF32_3());
553 execute(tc_oct2unichar_UTF32BE_3());
554 execute(tc_oct2unichar_UTF32LE_3());
555 execute(tc_oct2unichar_UTF32_4());
556 execute(tc_oct2unichar_UTF32BE_4());
557 execute(tc_oct2unichar_UTF32LE_4());
558 execute(tc_oct2unichar_UTF32_4_negative());
559 execute(tc_oct2unichar_UTF32BE_4_negative());
560 execute(tc_oct2unichar_UTF32LE_4_negative());
561 execute(tc_oct2unichar_UTF32BE_BMP_low());
562 execute(tc_oct2unichar_UTF32BE_BMP_hi());
563 execute(tc_oct2unichar_UTF32LE_BMP_low());
564 execute(tc_oct2unichar_UTF32LE_BMP_hi());
565 execute(tc_oct2unichar_UTF32());
566 execute(tc_oct2unichar_UTF32BE());
567 execute(tc_oct2unichar_UTF32LE());
568 execute(tc_unichar2oct_utf32_asciistring());
569 execute(tc_unichar2oct_utf32BE_asciistring());
570 execute(tc_unichar2oct_utf32LE_asciistring());
571 execute(tc_unichar2oct_utf32_upperplane_longer());
572 execute(tc_unichar2oct_utf32BE_upperplane_longer());
573 execute(tc_unichar2oct_utf32LE_upperplane_longer());