1 /******************************************************************************
2 * Copyright (c) 2000-2016 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
14 ******************************************************************************/
17 modulepar boolean Txerasntypes_verbose := false;
18 #define verbose Txerasntypes_verbose
20 #include "../macros.ttcnin"
22 import from Asntypes all;
23 import from AsnValues all;
26 type component ASN1 {}
28 //external function flatten(inout charstring par) ;
29 external function flatten(inout universal charstring par) ;
31 /**************************** BIT STRING ****************************/
32 DECLARE_XER_ENCODERS(Asn_bs,bs)
33 DECLARE_EXER_ENCODERS(Asn_bs,bs)
35 const charstring xer_fifteen := "<Asn-bs>00001111</Asn-bs>";
36 const charstring xer_pi1 := "<Asn-bs>0010010000111111011010101000100010000101101000110000100011010011"&
37 "0001001100011001100010100010111000000011011100000111001101000100"&
38 "1010010000001001001110000010001000101001100111110011000111010000"&
39 "0000100000101110111110101001100011101100010011100110110010001001</Asn-bs>";
40 const charstring xer_pi2 := "<Asn-bs>010001010010100000100001111001100011100011010000" &
41 "000100110111011110111110010101000110011011001111001101001110100100001100"&
42 "011011001100000010101100001010011011011111001001011111000101000011011101"&
43 "0011111110000100110101011011010110110101010001110000100100010111</Asn-bs>";
44 const charstring xer_bs_empty := "<Asn-bs/>";
46 testcase encode_bs() runs on ASN1 // BIT STRING
48 var Asn_bs bsval := '00001111'B;
49 var universal charstring expected := xer_fifteen;
51 CHECK_METHOD(cxer_enc_bs, bsval, expected);
52 CHECK_METHOD(bxer_enc_bs, bsval, expected & lf);
53 CHECK_METHOD(exer_enc_bs, bsval, expected & lf);
56 expected := xer_bs_empty;
57 CHECK_METHOD(cxer_enc_bs, bsval, expected);
58 CHECK_METHOD(bxer_enc_bs, bsval, expected & lf);
59 CHECK_METHOD(exer_enc_bs, bsval, expected & lf);
61 expected := xer_bs_empty; // FIXME: Asn-bs ?
62 CHECK_METHOD(cxer_enc_bs, AsnValues.bstr0, expected);
63 CHECK_METHOD(bxer_enc_bs, AsnValues.bstr0, expected & lf);
65 expected := "<Asn-bs>10100100</Asn-bs>";
66 CHECK_METHOD(cxer_enc_bs, AsnValues.bstr, expected);
67 CHECK_METHOD(bxer_enc_bs, AsnValues.bstr, expected & lf);
70 CHECK_METHOD(cxer_enc_bs, AsnValues.binpi2, expected);
71 CHECK_METHOD(bxer_enc_bs, AsnValues.binpi2, expected & lf);
74 CHECK_METHOD(cxer_enc_bs, AsnValues.binpi, expected);
75 CHECK_METHOD(bxer_enc_bs, AsnValues.binpi, expected & lf);
78 testcase decode_bs() runs on ASN1
83 CHECK_DECODE(cxer_dec_bs, xer_bs_empty, Asn_bs, expected);
84 CHECK_DECODE(bxer_dec_bs, xer_bs_empty, Asn_bs, expected);
85 CHECK_DECODE(exer_dec_bs, xer_bs_empty, Asn_bs, expected);
87 expected := '00001111'B;
88 CHECK_DECODE(cxer_dec_bs, xer_fifteen, Asn_bs, expected);
89 CHECK_DECODE(bxer_dec_bs, xer_fifteen, Asn_bs, expected);
90 CHECK_DECODE(exer_dec_bs, xer_fifteen, Asn_bs, expected);
92 expected := '0100010100101000001000011110011000111000110100000001001101110111101111100101010001100110110011110011010011101001000011000110110011000000101011000010100110110111110010010111110001010000110111010011111110000100110101011011010110110101010001110000100100010111'B;
93 CHECK_DECODE(cxer_dec_bs, xer_pi2, Asn_bs, expected);
94 CHECK_DECODE(bxer_dec_bs, xer_pi2, Asn_bs, expected);
95 CHECK_DECODE(exer_dec_bs, xer_pi2, Asn_bs, expected);
96 CHECK_DECODE(cxer_dec_bs, xer_pi2, Asn_bs, AsnValues.binpi2);
97 CHECK_DECODE(bxer_dec_bs, xer_pi2, Asn_bs, AsnValues.binpi2);
98 CHECK_DECODE(exer_dec_bs, xer_pi2, Asn_bs, AsnValues.binpi2);
100 expected := '0010010000111111011010101000100010000101101000110000100011010011000100110001100110001010001011100000001101110000011100110100010010100100000010010011100000100010001010011001111100110001110100000000100000101110111110101001100011101100010011100110110010001001'B;
101 CHECK_DECODE(cxer_dec_bs, xer_pi1, Asn_bs, AsnValues.binpi);
102 CHECK_DECODE(bxer_dec_bs, xer_pi1, Asn_bs, AsnValues.binpi);
103 CHECK_DECODE(exer_dec_bs, xer_pi1, Asn_bs, AsnValues.binpi);
106 /**************************** BOOLEAN ****************************/
107 DECLARE_XER_ENCODERS(Asn_bool, bool);
108 DECLARE_EXER_ENCODERS(Asn_bool,bool)
109 DECLARE_XER_ENCODERS(A_rboolean, arbool);
110 DECLARE_EXER_ENCODERS(A_rboolean,arbool)
112 testcase encode_abool() runs on ASN1
114 var Asn_bool boolval := true;
115 var universal charstring expected := "<Asn-bool><true/></Asn-bool>";
116 CHECK_METHOD(cxer_enc_bool, boolval, expected);
117 CHECK_METHOD(bxer_enc_bool, boolval, expected & lf);
118 expected := "<Asn-bool>true</Asn-bool>"; // EXER uses TextBoolean
119 CHECK_METHOD(exer_enc_bool, boolval, expected & lf);
121 expected := "<Asn-bool><true/></Asn-bool>";
122 CHECK_METHOD(cxer_enc_bool, AsnValues.boo, expected);
123 CHECK_METHOD(bxer_enc_bool, AsnValues.boo, expected & lf);
125 CHECK_METHOD(cxer_enc_bool, AsnValues.so_true, expected);
126 CHECK_METHOD(bxer_enc_bool, AsnValues.so_true, expected & lf);
128 expected := "<Asn-bool>true</Asn-bool>"; // EXER uses TextBoolean
129 CHECK_METHOD(exer_enc_bool, AsnValues.boo, expected & lf);
130 CHECK_METHOD(exer_enc_bool, AsnValues.so_true, expected & lf);
133 expected := "<Asn-bool><false/></Asn-bool>";
134 CHECK_METHOD(cxer_enc_bool, boolval, expected);
135 CHECK_METHOD(bxer_enc_bool, boolval, expected & lf);
136 expected := "<Asn-bool>false</Asn-bool>"; // EXER uses TextBoolean
137 CHECK_METHOD(exer_enc_bool, boolval, expected & lf);
139 expected := "<Asn-bool><false/></Asn-bool>";
140 CHECK_METHOD(cxer_enc_bool, AsnValues.noo, expected);
141 CHECK_METHOD(bxer_enc_bool, AsnValues.noo, expected & lf);
142 expected := "<Asn-bool>false</Asn-bool>"; // EXER uses TextBoolean
143 CHECK_METHOD(exer_enc_bool, AsnValues.noo, expected & lf);
145 expected := "<A-rboolean/>\n\n";
146 CHECK_METHOD(bxer_enc_arbool, AsnValues.arbomit, expected);
147 CHECK_METHOD(exer_enc_arbool, AsnValues.arbomit, expected);
149 CHECK_METHOD(cxer_enc_arbool, AsnValues.arbomit, expected & lf);
153 "\t<bb><true/></bb>\n" &
155 CHECK_METHOD(bxer_enc_arbool, AsnValues.arbtrue, expected);
157 CHECK_METHOD(cxer_enc_arbool, AsnValues.arbtrue, expected & lf);
160 "\t<bb>true</bb>\n" & // EXER uses TextBoolean
162 CHECK_METHOD(exer_enc_arbool, AsnValues.arbtrue, expected);
166 "\t<bb><false/></bb>\n" &
168 CHECK_METHOD(bxer_enc_arbool, AsnValues.arbfalse, expected);
170 CHECK_METHOD(cxer_enc_arbool, AsnValues.arbfalse, expected & lf);
173 "\t<bb>false</bb>\n" &
175 CHECK_METHOD(exer_enc_arbool, AsnValues.arbfalse, expected);
178 testcase decode_abool() runs on ASN1
181 var Asn_bool expected;
183 const charstring verite := "<Asn-bool><true/></Asn-bool>";
185 CHECK_DECODE2(bool, verite, Asn_bool, expected);
187 const charstring faux := "<Asn-bool><false/></Asn-bool>"
189 CHECK_DECODE2(bool, faux, Asn_bool, expected);
193 var A_rboolean expected := { omit };
194 const charstring omitted := "<A-rboolean/>\n\n";
195 CHECK_DECODE2(arbool, omitted, A_rboolean, expected);
199 var A_rboolean expected := { true };
200 const charstring one_true :=
202 "\t<bb><true/></bb>\n" &
204 CHECK_DECODE2(arbool, one_true, A_rboolean, expected);
208 var A_rboolean expected := { false };
209 const charstring one_true :=
211 "\t<bb><false/></bb>\n" &
213 CHECK_DECODE2(arbool, one_true, A_rboolean, expected);
217 /**************************** EMBEDDED PDV ****************************/
218 DECLARE_XER_ENCODERS(Asn_pdv, pdv);
219 DECLARE_EXER_ENCODERS(Asn_pdv,pdv)
221 const charstring pdvstr_syntax :=
223 "\t<identification>\n" &
224 "\t\t<syntax>0.4.0.0.1.2</syntax>\n" &
225 "\t</identification>\n" &
226 "\t<data-value>BABEFACE</data-value>\n" &
229 const charstring pdvstr_pci := // pci = initials of presentation-context-id
231 "\t<identification>\n" &
232 "\t\t<presentation-context-id>1</presentation-context-id>\n" &
233 "\t</identification>\n" &
234 "\t<data-value>BABEFACE</data-value>\n" &
237 const charstring pdvstr_syntaxes :=
239 "\t<identification>\n" &
241 "\t\t\t<abstract>1.0.9.8.7.6.5</abstract>\n" &
242 "\t\t\t<transfer>1.0.5.6.7.8.9</transfer>\n" &
243 "\t\t</syntaxes>\n" &
244 "\t</identification>\n" &
245 //"\t<data-value-descriptor>Food given to cattle</data-value-descriptor>\n" &
246 "\t<data-value>BEEFFEED</data-value>\n" &
249 const charstring pdvstr_syntax2 :=
251 "\t<identification>\n" &
252 "\t\t<syntax>0.4.0.1.3.5</syntax>\n" &
253 "\t</identification>\n" &
254 //"\t<data-value-descriptor>We need real coffee</data-value-descriptor>\n" &
255 "\t<data-value>DECAFBAD</data-value>\n" &
258 const charstring pdvstr_context_neg :=
260 "\t<identification>\n" &
261 "\t\t<context-negotiation>\n" &
262 "\t\t\t<presentation-context-id>69</presentation-context-id>\n" &
263 "\t\t\t<transfer-syntax>2.7.18.28.18.28.45.90.45</transfer-syntax>\n" &
264 "\t\t</context-negotiation>\n" &
265 "\t</identification>\n" &
266 "\t<data-value>C1AFB1</data-value>\n" &
269 const charstring pdvstr_xfer :=
271 "\t<identification>\n" &
272 "\t\t<transfer-syntax>0.4.0.0.1.2</transfer-syntax>\n" &
273 "\t</identification>\n" &
274 "\t<data-value>C0FFEE</data-value>\n" &
277 const charstring pdvstr_fixed :=
279 "\t<identification>\n" &
281 "\t</identification>\n" &
282 "\t<data-value>F1</data-value>\n" &
285 const Asn_pdv tpdv := {
286 { syntax := objid { etsi 0 1 2 } },
287 omit, // data-value-descriptor not allowed for EMBEDDED PDV
290 testcase encode_pdv() runs on ASN1
292 var universal charstring expected;
294 expected := pdvstr_syntax;
295 CHECK_METHOD(bxer_enc_pdv, tpdv, expected);
296 CHECK_METHOD(exer_enc_pdv, tpdv, expected);
298 CHECK_METHOD(cxer_enc_pdv, tpdv, expected);
300 expected := pdvstr_pci;
301 CHECK_METHOD(bxer_enc_pdv, AsnValues.pdv_pci, expected);
302 CHECK_METHOD(bxer_enc_pdv, AsnValues.epdv_pci, expected);
304 CHECK_METHOD(cxer_enc_pdv, AsnValues.pdv_pci, expected);
305 CHECK_METHOD(cxer_enc_pdv, AsnValues.epdv_pci, expected);
307 expected := pdvstr_syntaxes;
308 CHECK_METHOD(bxer_enc_pdv, AsnValues.pdv_sxs, expected);
309 CHECK_METHOD(bxer_enc_pdv, AsnValues.epdv_sxs, expected);
311 CHECK_METHOD(cxer_enc_pdv, AsnValues.pdv_sxs, expected);
312 CHECK_METHOD(cxer_enc_pdv, AsnValues.epdv_sxs, expected);
314 expected := pdvstr_syntax2;
315 CHECK_METHOD(bxer_enc_pdv, AsnValues.pdv_sx, expected);
316 CHECK_METHOD(bxer_enc_pdv, AsnValues.epdv_sx, expected);
318 CHECK_METHOD(cxer_enc_pdv, AsnValues.pdv_sx, expected);
319 CHECK_METHOD(cxer_enc_pdv, AsnValues.epdv_sx, expected);
321 expected := pdvstr_context_neg;
322 CHECK_METHOD(bxer_enc_pdv, AsnValues.pdv_cneg, expected);
323 CHECK_METHOD(bxer_enc_pdv, AsnValues.epdv_cneg, expected);
325 CHECK_METHOD(cxer_enc_pdv, AsnValues.pdv_cneg, expected);
326 CHECK_METHOD(cxer_enc_pdv, AsnValues.epdv_cneg, expected);
328 expected := pdvstr_xfer;
329 CHECK_METHOD(bxer_enc_pdv, AsnValues.pdv_xsx, expected);
330 CHECK_METHOD(bxer_enc_pdv, AsnValues.epdv_xsx, expected);
332 CHECK_METHOD(cxer_enc_pdv, AsnValues.pdv_xsx, expected);
333 CHECK_METHOD(cxer_enc_pdv, AsnValues.epdv_xsx, expected);
335 expected := pdvstr_fixed;
336 CHECK_METHOD(bxer_enc_pdv, AsnValues.pdv_fix, expected);
337 CHECK_METHOD(bxer_enc_pdv, AsnValues.epdv_fix, expected);
339 CHECK_METHOD(cxer_enc_pdv, AsnValues.pdv_fix, expected);
340 CHECK_METHOD(cxer_enc_pdv, AsnValues.epdv_fix, expected);
343 testcase decode_pdv() runs on ASN1
345 var Asn_pdv expected;
347 expected := AsnValues.pdv_sxs;
348 CHECK_DECODE2(pdv, pdvstr_syntaxes, Asn_pdv, expected);
350 expected := AsnValues.pdv_sx;
351 CHECK_DECODE2(pdv, pdvstr_syntax2, Asn_pdv, expected);
353 expected := AsnValues.pdv_pci;
354 CHECK_DECODE2(pdv, pdvstr_pci, Asn_pdv, expected);
356 expected := AsnValues.pdv_cneg;
357 CHECK_DECODE2(pdv, pdvstr_context_neg, Asn_pdv, expected);
359 expected := AsnValues.pdv_xsx;
360 CHECK_DECODE2(pdv, pdvstr_xfer, Asn_pdv, expected);
362 expected := AsnValues.pdv_fix;
363 CHECK_DECODE2(pdv, pdvstr_fixed, Asn_pdv, expected);
369 /**************************** EXTERNAL ****************************/
370 DECLARE_XER_ENCODERS(Asn_ext, ext);
371 DECLARE_EXER_ENCODERS(Asn_ext,ext)
373 type record extwrap {
377 DECLARE_XER_ENCODERS(extwrap, extw);
378 DECLARE_EXER_ENCODERS(extwrap,extw)
380 const charstring ext_octet_aligned :=
382 "\t<indirect-reference>66</indirect-reference>\n" &
384 "\t\t<octet-aligned>DECAFBAD</octet-aligned>\n" &
388 const charstring ext_octet_aligned2 :=
390 "\t<indirect-reference>2</indirect-reference>\n" &
392 "\t\t<octet-aligned>BABEFACE</octet-aligned>\n" &
396 const charstring ext_syntax_direct :=
398 "\t<direct-reference>2.7.18.28.18.28.45.90.45</direct-reference>\n" &
399 "\t<data-value-descriptor>using syntax, direct only</data-value-descriptor>\n" &
401 "\t\t<octet-aligned>BAADF00D</octet-aligned>\n" &
405 const charstring ext_context_both :=
407 "\t<direct-reference>2.1.1</direct-reference>\n" &
408 "\t<indirect-reference>111</indirect-reference>\n" &
409 "\t<data-value-descriptor>using context negotiation, both</data-value-descriptor>\n" &
411 "\t\t<octet-aligned>1337D00D</octet-aligned>\n" &
416 const charstring ext_octet_aligned_wrap :=
419 "\t\t<indirect-reference>66</indirect-reference>\n" &
421 "\t\t\t<octet-aligned>DECAFBAD</octet-aligned>\n" &
422 "\t\t</encoding>\n" &
426 const charstring ext_syntax_direct_wrap :=
429 "\t\t<direct-reference>2.7.18.28.18.28.45.90.45</direct-reference>\n" &
430 "\t\t<data-value-descriptor>using syntax, direct only</data-value-descriptor>\n" &
432 "\t\t\t<octet-aligned>BAADF00D</octet-aligned>\n" &
433 "\t\t</encoding>\n" &
437 const Asn_ext extval := {
438 { presentation_context_id := 66 },
443 testcase encode_ext() runs on ASN1
445 var universal charstring expected := ext_octet_aligned;
446 CHECK_METHOD(bxer_enc_ext, extval, expected);
447 CHECK_METHOD(exer_enc_ext, extval, expected);
449 CHECK_METHOD(cxer_enc_ext, extval, expected);
451 expected := ext_octet_aligned2;
452 CHECK_METHOD(bxer_enc_ext, AsnValues.ext, expected);
454 CHECK_METHOD(cxer_enc_ext, AsnValues.ext, expected);
456 expected := ext_syntax_direct;
457 CHECK_METHOD(bxer_enc_ext, AsnValues.ext_sx, expected);
459 CHECK_METHOD(cxer_enc_ext, AsnValues.ext_sx, expected);
461 expected := ext_context_both;
462 CHECK_METHOD(bxer_enc_ext, AsnValues.ext_cn, expected);
464 CHECK_METHOD(cxer_enc_ext, AsnValues.ext_cn, expected);
466 var extwrap xw := { SEQUENCE := extval }
467 expected := ext_octet_aligned_wrap;
469 CHECK_METHOD(bxer_enc_extw, xw, expected);
470 CHECK_METHOD(exer_enc_extw, xw, expected);
472 CHECK_METHOD(cxer_enc_extw, xw, expected & lf);
475 testcase decode_ext() runs on ASN1
477 var Asn_ext expected := extval;
479 CHECK_DECODE2(ext, ext_octet_aligned, Asn_ext, expected);
481 CHECK_DECODE2(ext, ext_octet_aligned2, Asn_ext, AsnValues.ext);
483 CHECK_DECODE2(ext, ext_syntax_direct, Asn_ext, AsnValues.ext_sx);
485 CHECK_DECODE2(ext, ext_context_both, Asn_ext, AsnValues.ext_cn);
487 var extwrap expectedw := { SEQUENCE := extval };
488 var universal charstring xwrap := ext_octet_aligned_wrap;
489 CHECK_DECODE2(extw, xwrap, extwrap, expectedw);
491 expectedw := { SEQUENCE := AsnValues.ext_sx };
492 xwrap := ext_syntax_direct_wrap;
493 CHECK_DECODE2(extw, xwrap, extwrap, expectedw);
496 /**************************** INTEGER ****************************/
497 DECLARE_XER_ENCODERS(Asn_int, aint);
498 DECLARE_EXER_ENCODERS(Asn_int,aint)
500 testcase encode_aint() runs on ASN1
502 var Asn_int intval := -137;
503 var universal charstring expected := "<Asn-int>-137</Asn-int>";
505 // It can never do that. Unbound should cause an error.
506 CHECK_METHOD(cxer_enc_aint, intval, expected);
507 CHECK_METHOD(bxer_enc_aint, intval, expected & lf);
508 CHECK_METHOD(exer_enc_aint, intval, expected & lf);
510 expected := "<Asn-int>42</Asn-int>";
511 CHECK_METHOD(cxer_enc_aint, AsnValues.fourty_two, expected);
512 CHECK_METHOD(bxer_enc_aint, AsnValues.fourty_two, expected & lf);
514 expected := "<Asn-int>0</Asn-int>";
515 CHECK_METHOD(cxer_enc_aint, AsnValues.zarro, expected);
516 CHECK_METHOD(bxer_enc_aint, AsnValues.zarro, expected & lf);
519 CHECK_METHOD(cxer_enc_aint, intval, expected);
520 CHECK_METHOD(bxer_enc_aint, intval, expected & lf);
521 CHECK_METHOD(exer_enc_aint, intval, expected & lf);
523 expected := "<Asn-int>602214179000000000000000</Asn-int>";
524 CHECK_METHOD(cxer_enc_aint, AsnValues.avogadro, expected);
525 CHECK_METHOD(bxer_enc_aint, AsnValues.avogadro, expected & lf);
527 // This is somewhat redundant because [bc]xer_enc_int doesn't encode
528 // a TTCN3 integer (see Txerint.ttcnpp for that), but an Asn_int.
529 intval := 602214179000000000000000;
530 CHECK_METHOD(cxer_enc_aint, intval, expected);
531 CHECK_METHOD(bxer_enc_aint, intval, expected & lf);
532 CHECK_METHOD(exer_enc_aint, intval, expected & lf);
535 testcase decode_aint() runs on ASN1
537 var integer expected;
538 const charstring one_three_seven := "<Asn-int>137</Asn-int>";
540 CHECK_DECODE2(aint, one_three_seven, integer, expected);
542 const charstring minus_nine := "<Asn-int>-9</Asn-int>";
544 CHECK_DECODE2(aint, minus_nine, integer, expected);
546 const charstring fourtytwo := "<Asn-int>42</Asn-int>";
547 CHECK_DECODE2(aint, fourtytwo, integer, AsnValues.fourty_two);
549 const charstring nix := "<Asn-int>0</Asn-int>";
550 CHECK_DECODE2(aint, nix, integer, AsnValues.zarro);
551 const charstring minix := "<Asn-int>-0</Asn-int>";
552 CHECK_DECODE2(aint, minix, integer, AsnValues.zarro);
554 const charstring avo := "<Asn-int>602214179000000000000000</Asn-int>";
555 expected := 602214179000000000000000;
556 CHECK_DECODE2(aint, avo, Asn_int, expected);
558 const charstring empty_int := "<Asn-int/>";
559 var octetstring bytes;
560 var integer rv := u2o("UTF-8", empty_int, bytes);
561 MUST_UNBOUND(bxer_dec_aint(bytes)); // can't check with ==
564 /**************************** NULL ****************************/
565 DECLARE_XER_ENCODERS(Asn_nul, nul);
566 DECLARE_EXER_ENCODERS(Asn_nul,nul)
568 testcase encode_nul() runs on ASN1
570 var Asn_nul nulval := NULL;
571 var universal charstring expected := "<Asn-nul/>";
572 CHECK_METHOD(cxer_enc_nul, nulval, expected);
573 CHECK_METHOD(bxer_enc_nul, nulval, expected & lf);
574 CHECK_METHOD(exer_enc_nul, nulval, expected & lf);
577 testcase decode_nul() runs on ASN1
579 const charstring nullstr := "<Asn-nul/>";
580 var Asn_nul expected := NULL;
581 CHECK_DECODE2(nul, nullstr, Asn_nul, expected);
584 /**************************** OBJECT IDENTIFIER ****************************/
585 DECLARE_XER_ENCODERS(Asn_oid, oid);
586 DECLARE_EXER_ENCODERS(Asn_oid,oid)
588 const charstring oidstr_empty := "<Asn-oid/>";
589 const charstring oidstr_etsiMobNet := "<Asn-oid>0.4.0.0.1</Asn-oid>";
590 const charstring oidstr_pi := "<Asn-oid>1.3.14.15.9.2.6.5.3.5.8.9.7.9.3.2.3.8.4.6.2.6.4.3.3</Asn-oid>";
591 const charstring oidstr_e := "<Asn-oid>2.7.18.28.18.28.45.90.45</Asn-oid>";
592 const charstring oidstr_ericsson_testing := "<Asn-oid>0.4.0.127.0.5.0</Asn-oid>";
593 const charstring oidstr_etsi_solo := "<Asn-oid>0.4.0</Asn-oid>";
594 const charstring oidstr_ber := "<Asn-oid>2.1.1</Asn-oid>";
595 const charstring oidstr_cer := "<Asn-oid>2.6.6.1.2.4.4</Asn-oid>";
597 const Asn_oid etsiMobNet := objid{ itu_t identified_organization etsi(0) mobile_domain(0) umts_Network(1) }
599 testcase encode_oid() runs on ASN1
602 var universal charstring expected := oidstr_empty;
604 // unbound! CHECK_METHOD(cxer_enc_oid, noid, expected);
605 // unbound! CHECK_METHOD(bxer_enc_oid, noid, expected & lf);
607 expected := oidstr_etsiMobNet;
609 expected := oidstr_pi
610 CHECK_METHOD(cxer_enc_oid, pi_oid, expected);
611 CHECK_METHOD(bxer_enc_oid, pi_oid, expected & lf);
612 CHECK_METHOD(exer_enc_oid, pi_oid, expected & lf);
614 expected := oidstr_e;
615 CHECK_METHOD(cxer_enc_oid, e_oid, expected);
616 CHECK_METHOD(bxer_enc_oid, e_oid, expected & lf);
617 CHECK_METHOD(exer_enc_oid, e_oid, expected & lf);
619 // { itu-t identified-organization etsi(0) reserved(127) etsi-identified-organization(0) ericsson(5) testing(0) }
620 expected := oidstr_ericsson_testing;
621 CHECK_METHOD(cxer_enc_oid, ericsson_testing, expected);
622 CHECK_METHOD(bxer_enc_oid, ericsson_testing, expected & lf);
623 CHECK_METHOD(exer_enc_oid, ericsson_testing, expected & lf);
625 expected := oidstr_etsi_solo;
626 CHECK_METHOD(cxer_enc_oid, etsi_solo, expected);
627 CHECK_METHOD(bxer_enc_oid, etsi_solo, expected & lf);
628 CHECK_METHOD(exer_enc_oid, etsi_solo, expected & lf);
630 expected := oidstr_ber;
631 CHECK_METHOD(cxer_enc_oid, ber_oid, expected);
632 CHECK_METHOD(bxer_enc_oid, ber_oid, expected & lf);
633 CHECK_METHOD(exer_enc_oid, ber_oid, expected & lf);
635 expected := oidstr_cer;
636 CHECK_METHOD(cxer_enc_oid, cer_oid, expected);
637 CHECK_METHOD(bxer_enc_oid, cer_oid, expected & lf);
638 CHECK_METHOD(exer_enc_oid, cer_oid, expected & lf);
641 testcase decode_oid() runs on ASN1
643 var Asn_oid expected;
644 //compiler error, must have at least two components := objid { 1 };
645 //CHECK_DECODE2(oid, oidstr_empty, Asn_oid, expected);
647 expected := etsiMobNet;
648 CHECK_DECODE2(oid, oidstr_etsiMobNet, Asn_oid, expected);
651 CHECK_DECODE2(oid, oidstr_pi, Asn_oid, expected);
654 CHECK_DECODE2(oid, oidstr_e, Asn_oid, expected);
656 expected := ericsson_testing;
657 CHECK_DECODE2(oid, oidstr_ericsson_testing, Asn_oid, expected);
659 expected := etsi_solo;
660 CHECK_DECODE2(oid, oidstr_etsi_solo, Asn_oid, expected);
663 CHECK_DECODE2(oid, oidstr_ber, Asn_oid, expected);
666 CHECK_DECODE2(oid, oidstr_cer, Asn_oid, expected);
669 /**************************** RELATIVE OBJECT IDENTIFIER ****************************/
670 DECLARE_XER_ENCODERS(Asn_roid, roid);
671 DECLARE_EXER_ENCODERS(Asn_roid,roid)
673 testcase encode_roid() runs on ASN1
676 var universal charstring expected := "<Asn-roid/>";
677 // unbound! CHECK_METHOD(cxer_enc_roid, roidval, expected);
678 // unbound! CHECK_METHOD(bxer_enc_roid, roidval, expected & lf);
680 roidval := objid {iso(1) member_body(2) bsi(826) disc(0) ericsson(1249)};
681 expected := "<Asn-roid>1.2.826.0.1249</Asn-roid>";
682 CHECK_METHOD(cxer_enc_roid, roidval, expected);
683 CHECK_METHOD(bxer_enc_roid, roidval, expected & lf);
684 CHECK_METHOD(exer_enc_roid, roidval, expected & lf);
686 CHECK_METHOD(cxer_enc_roid, AsnValues.zoid, expected);
687 CHECK_METHOD(bxer_enc_roid, AsnValues.zoid, expected & lf);
690 testcase decode_roid() runs on ASN1
692 var Asn_oid expected;
693 expected := objid {iso(1) member_body(2) bsi(826) disc(0) ericsson(1249)};
694 CHECK_DECODE2(roid, "<Asn-roid>1.2.826.0.1249</Asn-roid>", Asn_oid, expected);
697 /**************************** OCTET STRING ****************************/
698 DECLARE_XER_ENCODERS(Asn_os,os)
699 DECLARE_EXER_ENCODERS(Asn_os,os)
701 const charstring ostr_1111 := "<Asn-os>00001111</Asn-os>";
702 const charstring ostr_empty := "<Asn-os/>";
703 const charstring ostr_0123 := "<Asn-os>00112233</Asn-os>";
705 testcase encode_os() runs on ASN1 // OCTET STRING
707 var Asn_os osval := '00001111'O;
708 var universal charstring expected := ostr_1111;
709 //var charstring encoded := bxer_enc_bs(bsval);
710 CHECK_METHOD(cxer_enc_os, osval, expected);
711 CHECK_METHOD(bxer_enc_os, osval, expected & lf);
712 CHECK_METHOD(exer_enc_os, osval, expected & lf);
715 expected := ostr_empty;
716 CHECK_METHOD(cxer_enc_os, osval, expected);
717 CHECK_METHOD(bxer_enc_os, osval, expected & lf);
718 CHECK_METHOD(exer_enc_os, osval, expected & lf);
719 // still empty expected
720 CHECK_METHOD(cxer_enc_os, AsnValues.os0, expected);
721 CHECK_METHOD(bxer_enc_os, AsnValues.os0, expected & lf);
723 expected := ostr_0123;
724 CHECK_METHOD(cxer_enc_os, AsnValues.os, expected);
725 CHECK_METHOD(bxer_enc_os, AsnValues.os, expected & lf);
728 testcase decode_os() runs on ASN1 // OCTET STRING
732 expected := '00001111'O;
733 CHECK_DECODE2(os, ostr_1111, Asn_os, expected);
736 CHECK_DECODE2(os, ostr_empty, Asn_os, expected);
738 expected := AsnValues.os
739 CHECK_DECODE2(os, ostr_0123, Asn_os, expected);
742 /**************************** REAL ****************************/
743 DECLARE_XER_ENCODERS(Asn_real, real);
744 DECLARE_EXER_ENCODERS(Asn_real,real)
746 const charstring floatstr_pi := "<Asn-real>3.141593</Asn-real>";
747 const charstring floatstr_longpi := "<Asn-real>3.14159265358979</Asn-real>";
749 testcase encode_real() runs on ASN1
751 var Asn_real rval := 3.1415926;
752 var universal charstring expected := floatstr_pi;
754 // It can never do that. Unbound should cause an error.
755 CHECK_METHOD(cxer_enc_real, rval, expected);
756 CHECK_METHOD(bxer_enc_real, rval, expected & lf);
757 CHECK_METHOD(exer_enc_real, rval, expected & lf);
759 CHECK_METHOD(cxer_enc_real, AsnValues.pi, expected);
760 CHECK_METHOD(bxer_enc_real, AsnValues.pi, expected & lf);
763 testcase decode_real() runs on ASN1
765 var float expected := 3.141593;
767 CHECK_DECODE2(real, floatstr_pi, float, expected);
769 CHECK_DECODE2(real, floatstr_longpi, float, AsnValues.pi);
772 /**************************** Strings ****************************/
773 DECLARE_XER_ENCODERS(Asn_ia5, ia5s);
774 DECLARE_EXER_ENCODERS(Asn_ia5,ia5s)
776 const charstring ia5_yay := "<Asn-ia5>Yay!</Asn-ia5>\n";
777 const charstring ia5_cthulhu := "<Asn-ia5>Ia5! Ia5! Cthulhu fhtagn!</Asn-ia5>\n";
778 const charstring ia5_empty := "<Asn-ia5/>\n";
779 const charstring ia5_bonafide := "<Asn-ia5>A bona fide IA5String</Asn-ia5>\n";
781 testcase encode_ia5str() runs on ASN1
783 var Asn_ia5 rval := "Yay!";
784 var universal charstring expected := ia5_yay;
785 CHECK_METHOD(cxer_enc_ia5s, rval, expected);
786 CHECK_METHOD(bxer_enc_ia5s, rval, expected & lf);
787 CHECK_METHOD(exer_enc_ia5s, rval, expected & lf);
789 expected := ia5_cthulhu;
790 CHECK_METHOD(cxer_enc_ia5s, AsnValues.ia5val, expected);
791 CHECK_METHOD(bxer_enc_ia5s, AsnValues.ia5val, expected & lf);
793 expected := ia5_empty;
794 CHECK_METHOD(cxer_enc_ia5s, AsnValues.ia6val, expected);
795 CHECK_METHOD(bxer_enc_ia5s, AsnValues.ia6val, expected & lf);
797 expected := ia5_bonafide;
798 CHECK_METHOD(cxer_enc_ia5s, AsnValues.ia7val, expected);
799 CHECK_METHOD(bxer_enc_ia5s, AsnValues.ia7val, expected & lf);
801 expected := ia5_empty;
802 CHECK_METHOD(cxer_enc_ia5s, AsnValues.ia8val, expected);
803 CHECK_METHOD(bxer_enc_ia5s, AsnValues.ia8val, expected & lf);
806 testcase decode_ia5str() runs on ASN1
808 var charstring expected;
811 CHECK_DECODE2(ia5s, ia5_yay, Asn_ia5, expected);
813 expected := AsnValues.ia5val;
814 CHECK_DECODE2(ia5s, ia5_cthulhu, Asn_ia5, expected);
816 expected := AsnValues.ia6val;
817 CHECK_DECODE2(ia5s, ia5_empty, Asn_ia5, expected);
819 expected := AsnValues.ia7val;
820 CHECK_DECODE2(ia5s, ia5_bonafide, Asn_ia5, expected);
823 /**************************** UTF8String ****************************/
824 DECLARE_XER_ENCODERS(Asn_utf, utf);
825 DECLARE_EXER_ENCODERS(Asn_utf,utf)
827 // XER encoding of "UTF8 A'RVI'ZTU"RO"" TU:KO:RFU'RO'GE'P"
828 const universal charstring utf_arviz_turo :=
829 "<Asn-utf>UTF8 " & Aacute & "RV" & Iacute & "ZT" & Udouble & "R" & Odouble &
830 " T" & Uuml & "K" & Ouml & "RF" & Uacute & "R" & Oacute & "G" & Eacute & "P</Asn-utf>\n";
832 // XER encoding of an empty string
833 const charstring utf_empty := "<Asn-utf/>\n";
835 // XER encoding which needs to do a lot of escaping
836 const universal charstring utf_esc_oss :=
837 "<Asn-utf>UTF8 escapology\n<soh/><stx/><etx/><eot/><enq/><ack/><bel/><bs/>\t\n<vt/><ff/>\r<so/><si/><dle/><dc1/><dc2/><dc3/><dc4/><nak/><syn/><etb/><can/><em/><sub/><esc/><is4/><is3/><is2/><is1/>" &
838 //these would be the UTF8 bytes: "\xc2\x84\xC5\x82\xE4\x89\x82\xF0\x94\x89\x82\xF4\x84\x89\x82</Asn-utf>\n";
839 //but universal charstring uses UCS4
840 char(0,0,0,132) & char(0,0,1,66) & char(0,0,66,66) & char(0,1,66,66) & char(0,16,66,66) & "</Asn-utf>\n";
842 // An alternative representation which should decode into the same value
843 const universal charstring utf_esc_oss_alt :=
844 "<Asn-utf>UTF8 escapology\n<soh/><stx/><etx/><eot/><enq/><ack/><bel/><bs/>\t\n<vt/><ff/>\r<so/><si/><dle/><dc1/><dc2/><dc3/><dc4/><nak/><syn/><etb/><can/><em/><sub/><esc/><is4/><is3/><is2/><is1/>" &
845 // libxml2 handles &#n; and &#xn; for us. But it won't accept control characters.
846 "„ł䉂𔉂􄉂" & "</Asn-utf>\n";
848 const universal charstring utf_bogus :=
849 "<Asn-utf>UTF8 escapology\n<doh/><stx/><etx/><eot/><enq/><ack/><bel/><bs/>\t\n<vt/><ff/>\r<so/><si/><dle/><dc1/><dc2/><dc3/><dc4/><nak/><syn/><etb/><can/><em/><sub/><esc/><is4/><is3/><is2/><is1/>" &
850 //--------------------------^^^
851 char(0,0,0,132) & char(0,0,1,66) & char(0,0,66,66) & char(0,1,66,66) & char(0,16,66,66) & "</Asn-utf>\n";
853 // XER encoding which needs to do a lot of escaping:
854 // "UTF8 " followed by "\x01\x02...\x1F" then \x84\x0142\x4242\x00014242\x00104242
855 //const charstring utf_esc :=
856 //"<Asn-utf>UTF8\n\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F" &
857 //"\xc2\x84\xC5\x82\xE4\x89\x82\xF0\x94\x89\x82\xF4\x84\x89\x82</Asn-utf>\n";
859 // XER encoding of an HTML fragment
860 const charstring utf_html :=
861 "<Asn-utf><html><body onload='javascript.alert("UTF8")'>&nbsp;</body></html></Asn-utf>\n";
863 testcase encode_utf() runs on ASN1
865 // Encode "UTF8 A'RVI'ZTU"RO"" TU:KO:RFU'RO'GE'P"
866 var universal charstring expected := utf_arviz_turo;
867 CHECK_METHOD(cxer_enc_utf, AsnValues.val_utf, expected);
868 CHECK_METHOD(bxer_enc_utf, AsnValues.val_utf, expected & lf);
870 // Encode an empty string
871 expected := utf_empty;
872 CHECK_METHOD(cxer_enc_utf, AsnValues.blank_utf, expected);
873 CHECK_METHOD(bxer_enc_utf, AsnValues.blank_utf, expected & lf);
875 // Encode a string with lots of characters that need to be escaped:
876 expected := utf_esc_oss;
877 CHECK_METHOD(cxer_enc_utf, AsnValues.esc_utf, expected);
878 CHECK_METHOD(bxer_enc_utf, AsnValues.esc_utf, expected & lf);
880 expected := utf_html;
881 CHECK_METHOD(cxer_enc_utf, AsnValues.html_utf, expected);
882 CHECK_METHOD(bxer_enc_utf, AsnValues.html_utf, expected & lf);
885 testcase decode_utf() runs on ASN1
887 var Asn_utf expected;
889 expected := AsnValues.val_utf;
890 CHECK_DECODE2(utf, utf_arviz_turo, Asn_utf, expected);
892 expected := AsnValues.blank_utf;
893 CHECK_DECODE2(utf, utf_empty, Asn_utf, expected);
895 expected := AsnValues.esc_utf_dec;
896 CHECK_DECODE2(utf, utf_esc_oss, Asn_utf, expected);
897 CHECK_DECODE2(utf, utf_esc_oss_alt, Asn_utf, expected);
898 // Dynamic testcase error, as expected:
899 //CHECK_DECODE2(utf, utf_bogus, Asn_utf, expected);
901 expected := AsnValues.html_utf;
902 CHECK_DECODE2(utf, utf_html, Asn_utf, expected);
906 /**************** Other restricted character string types ****************/
907 DECLARE_XER_ENCODERS(Asn_bmp, bmp);
908 DECLARE_EXER_ENCODERS(Asn_bmp,bmp)
909 DECLARE_XER_ENCODERS(Asn_gen, gen);
910 DECLARE_EXER_ENCODERS(Asn_gen,gen)
911 DECLARE_XER_ENCODERS(Asn_gra, gra);
912 DECLARE_EXER_ENCODERS(Asn_gra,gra)
913 DECLARE_XER_ENCODERS(Asn_num, num);
914 DECLARE_EXER_ENCODERS(Asn_num,num)
915 DECLARE_XER_ENCODERS(Asn_prn, prn);
916 DECLARE_EXER_ENCODERS(Asn_prn,prn)
917 DECLARE_XER_ENCODERS(Asn_ttx, ttx);
918 DECLARE_EXER_ENCODERS(Asn_ttx,ttx)
919 DECLARE_XER_ENCODERS(Asn_uni, uni);
920 DECLARE_EXER_ENCODERS(Asn_uni,uni)
921 DECLARE_XER_ENCODERS(Asn_vtx, vtx);
922 DECLARE_EXER_ENCODERS(Asn_vtx,vtx)
923 DECLARE_XER_ENCODERS(Asn_vis, vis);
924 DECLARE_EXER_ENCODERS(Asn_vis,vis)
926 DECLARE_XER_ENCODERS(universal charstring, ustr);
928 const charstring str_bmp := "<Asn-bmp>Ich weiß es! Basic Multilingual Plane.</Asn-bmp>\n";
929 const charstring str_bmp0 := "<Asn-bmp/>\n";
930 const charstring str_bmp_esc :=
931 "<Asn-bmp>BMP\n<nul/><soh/><stx/><etx/><eot/><enq/><ack/><bel/><bs/>\t\n<vt/><ff/>\r<so/><si/><dle/><dc1/><dc2/><dc3/><dc4/><nak/><syn/><etb/><can/><em/><sub/><esc/><is4/><is3/><is2/><is1/>„ł䉂</Asn-bmp>\n";
932 const charstring str_bmp_html :=
933 "<Asn-bmp><html><body onload='javascript.alert("BMP")'>&nbsp;</body></html></Asn-bmp>\n";
935 const charstring str_gen0 := "<Asn-gen/>\n";
936 const charstring str_gen := "<Asn-gen>Who is General Failure and why is he reading my disk ?</Asn-gen>\n";
938 const charstring str_gra0 := "<Asn-gra/>\n";
939 const charstring str_gra := "<Asn-gra>Graphic</Asn-gra>\n";
941 const charstring str_num0 := "<Asn-num/>\n";
942 const charstring str_num := "<Asn-num>150130937545296572356771972164254457814047970568738777235893533016064</Asn-num>\n";
944 const charstring str_prn0 := "<Asn-prn/>\n";
945 const charstring str_prn := "<Asn-prn>Printable</Asn-prn>\n";
947 const charstring str_ttx0 := "<Asn-ttx/>\n";
948 const charstring str_ttx := "<Asn-ttx>Teletex</Asn-ttx>\n";
950 const charstring str_uni0 := "<Asn-uni/>\n";
951 const charstring str_uni := "<Asn-uni>Universal 灰羽árvíztűrő tükörfúrógép</Asn-uni>\n";
952 const charstring str_uni_esc := "<Asn-uni>Universal escapology\n<nul/><soh/><stx/><etx/><eot/><enq/><ack/><bel/><bs/>\t\n<vt/><ff/>\r<so/><si/><dle/><dc1/><dc2/><dc3/><dc4/><nak/><syn/><etb/><can/><em/><sub/><esc/><is4/><is3/><is2/><is1/>„ł䉂𔉂􄉂</Asn-uni>\n";
953 //�„ł䉂
954 const charstring str_uni_html:= "<Asn-uni><html><body onload='javascript.alert("Universal")'>&nbsp;</body></html></Asn-uni>\n";
956 const charstring str_vtx0 := "<Asn-vtx/>\n";
957 const charstring str_vtx := "<Asn-vtx>Videotex</Asn-vtx>\n";
959 const charstring str_vis0 := "<Asn-vis/>\n";
960 const charstring str_vis := "<Asn-vis>Visible (ISO646)</Asn-vis>\n";
964 testcase encode_restricted_strings() runs on ASN1
966 var universal charstring expected;
969 CHECK_METHOD(cxer_enc_bmp, AsnValues.b1val, expected);
970 CHECK_METHOD(bxer_enc_bmp, AsnValues.b1val, expected & lf);
972 expected := str_bmp0;
973 CHECK_METHOD(cxer_enc_bmp, AsnValues.b0val, expected);
974 CHECK_METHOD(bxer_enc_bmp, AsnValues.b0val, expected & lf);
976 expected := str_bmp_esc;
977 CHECK_METHOD(cxer_enc_bmp, AsnValues.esc_bmp, expected);
978 CHECK_METHOD(bxer_enc_bmp, AsnValues.esc_bmp, expected & lf);
980 expected := str_bmp_html;
981 CHECK_METHOD(cxer_enc_bmp, AsnValues.html_bmp, expected);
982 CHECK_METHOD(bxer_enc_bmp, AsnValues.html_bmp, expected & lf);
984 //----------------------------------------------------
985 expected := str_gen0;
986 CHECK_METHOD(cxer_enc_gen, AsnValues.g0val, expected);
987 CHECK_METHOD(bxer_enc_gen, AsnValues.g0val, expected & lf);
990 CHECK_METHOD(cxer_enc_gen, AsnValues.g1val, expected);
991 CHECK_METHOD(bxer_enc_gen, AsnValues.g1val, expected & lf);
993 //----------------------------------------------------
994 expected := str_gra0;
995 CHECK_METHOD(cxer_enc_gra, AsnValues.gr0val, expected);
996 CHECK_METHOD(bxer_enc_gra, AsnValues.gr0val, expected & lf);
999 CHECK_METHOD(cxer_enc_gra, AsnValues.gr1val, expected);
1000 CHECK_METHOD(bxer_enc_gra, AsnValues.gr1val, expected & lf);
1002 //----------------------------------------------------
1003 expected := str_num0;
1004 CHECK_METHOD(cxer_enc_num, AsnValues.blank_num, expected);
1005 CHECK_METHOD(bxer_enc_num, AsnValues.blank_num, expected & lf);
1007 expected := str_num;
1008 CHECK_METHOD(cxer_enc_num, AsnValues.val_num, expected);
1009 CHECK_METHOD(bxer_enc_num, AsnValues.val_num, expected & lf);
1011 //----------------------------------------------------
1012 expected := str_prn0;
1013 CHECK_METHOD(cxer_enc_prn, AsnValues.blank_prn, expected);
1014 CHECK_METHOD(bxer_enc_prn, AsnValues.blank_prn, expected & lf);
1016 expected := str_prn;
1017 CHECK_METHOD(cxer_enc_prn, AsnValues.val_prn, expected);
1018 CHECK_METHOD(bxer_enc_prn, AsnValues.val_prn, expected & lf);
1020 //----------------------------------------------------
1021 expected := str_ttx0;
1022 CHECK_METHOD(cxer_enc_ttx, AsnValues.blank_ttx, expected);
1023 CHECK_METHOD(bxer_enc_ttx, AsnValues.blank_ttx, expected & lf);
1025 expected := str_ttx;
1026 CHECK_METHOD(cxer_enc_ttx, AsnValues.val_ttx, expected);
1027 CHECK_METHOD(bxer_enc_ttx, AsnValues.val_ttx, expected & lf);
1029 //----------------------------------------------------
1030 expected := str_uni0;
1031 CHECK_METHOD(cxer_enc_uni, AsnValues.blank_uni, expected);
1032 CHECK_METHOD(bxer_enc_uni, AsnValues.blank_uni, expected & lf);
1034 expected := str_uni_esc;
1035 CHECK_METHOD(cxer_enc_uni, AsnValues.esc_uni, expected);
1036 CHECK_METHOD(bxer_enc_uni, AsnValues.esc_uni, expected & lf);
1038 expected := str_uni;
1039 CHECK_METHOD(cxer_enc_uni, AsnValues.val_uni, expected);
1040 CHECK_METHOD(bxer_enc_uni, AsnValues.val_uni, expected & lf);
1042 expected := str_uni_html;
1043 CHECK_METHOD(cxer_enc_uni, AsnValues.html_uni, expected);
1044 CHECK_METHOD(bxer_enc_uni, AsnValues.html_uni, expected & lf);
1046 //----------------------------------------------------
1047 expected := str_vtx0;
1048 CHECK_METHOD(cxer_enc_vtx, AsnValues.blank_vtx, expected);
1049 CHECK_METHOD(bxer_enc_vtx, AsnValues.blank_vtx, expected & lf);
1051 expected := str_vtx;
1052 CHECK_METHOD(cxer_enc_vtx, AsnValues.val_vtx, expected);
1053 CHECK_METHOD(bxer_enc_vtx, AsnValues.val_vtx, expected & lf);
1055 //----------------------------------------------------
1056 expected := str_vis0;
1057 CHECK_METHOD(cxer_enc_vis, AsnValues.blank_vis, expected);
1058 CHECK_METHOD(bxer_enc_vis, AsnValues.blank_vis, expected & lf);
1060 expected := str_vis;
1061 CHECK_METHOD(cxer_enc_vis, AsnValues.val_vis, expected);
1062 CHECK_METHOD(bxer_enc_vis, AsnValues.val_vis, expected & lf);
1065 testcase decode_restricted_strings() runs on ASN1
1068 var Asn_bmp expected;
1070 expected := AsnValues.b1val;
1071 CHECK_DECODE(cxer_dec_bmp, str_bmp, universal charstring, expected/*AsnValues.b1val*/);
1072 CHECK_DECODE(bxer_dec_bmp, str_bmp, universal charstring, expected /*& lf*/);
1074 expected := AsnValues.b0val;
1075 CHECK_DECODE(cxer_dec_bmp, str_bmp0, universal charstring, expected);
1076 CHECK_DECODE(bxer_dec_bmp, str_bmp0, universal charstring, expected /*& lf*/);
1078 expected := AsnValues.esc_bmp_dec;
1079 CHECK_DECODE(cxer_dec_bmp, str_bmp_esc, universal charstring, expected);
1080 CHECK_DECODE(bxer_dec_bmp, str_bmp_esc, universal charstring, expected /*& lf*/);
1082 expected := AsnValues.html_bmp;
1083 CHECK_DECODE(cxer_dec_bmp, str_bmp_html, universal charstring, expected);
1084 CHECK_DECODE(bxer_dec_bmp, str_bmp_html, universal charstring, expected /*& lf*/);
1086 //----------------------------------------------------
1088 var Asn_gen expected := AsnValues.g0val;
1089 CHECK_DECODE(cxer_dec_gen, str_gen0, Asn_gen, expected);
1090 CHECK_DECODE(bxer_dec_gen, str_gen0, Asn_gen, expected);
1092 expected := AsnValues.g1val;
1093 CHECK_DECODE(cxer_dec_gen, str_gen, Asn_gen, expected);
1094 CHECK_DECODE(bxer_dec_gen, str_gen, Asn_gen, expected);
1097 //----------------------------------------------------
1099 var Asn_gra expected := AsnValues.gr0val;
1100 CHECK_DECODE(cxer_dec_gra, str_gra0, Asn_gra, expected);
1101 CHECK_DECODE(bxer_dec_gra, str_gra0, Asn_gra, expected);
1103 expected := AsnValues.gr1val;
1104 CHECK_DECODE(cxer_dec_gra, str_gra, Asn_gra, expected);
1105 CHECK_DECODE(bxer_dec_gra, str_gra, Asn_gra, expected);
1108 //----------------------------------------------------
1110 var Asn_num expected := AsnValues.blank_num;
1111 CHECK_DECODE3(num, str_num0, expected); // checks both BXER and CXER
1113 expected := AsnValues.val_num;
1114 CHECK_DECODE3(num, str_num, expected);
1117 //----------------------------------------------------
1119 var Asn_prn expected := AsnValues.blank_prn;
1120 CHECK_DECODE3(prn, str_prn0, expected);
1122 expected := AsnValues.val_prn;
1123 CHECK_DECODE3(prn, str_prn, expected);
1126 //----------------------------------------------------
1128 var Asn_ttx expected := AsnValues.blank_ttx;
1129 CHECK_DECODE3(ttx, str_ttx0, expected);
1131 expected := AsnValues.val_ttx;
1132 CHECK_DECODE3(ttx, str_ttx, expected);
1135 //----------------------------------------------------
1137 var Asn_uni expected := AsnValues.blank_uni;
1138 CHECK_DECODE3(uni, str_uni0, expected);
1140 expected := AsnValues.esc_uni_dec;
1141 CHECK_DECODE3(uni, str_uni_esc, expected);
1143 expected := AsnValues.val_uni;
1144 CHECK_DECODE3(uni, str_uni, expected);
1146 expected := AsnValues.html_uni;
1147 CHECK_DECODE3(uni, str_uni_html, expected);
1150 //----------------------------------------------------
1152 var Asn_vtx expected := AsnValues.blank_vtx;
1153 CHECK_DECODE3(vtx, str_vtx0, expected);
1155 expected := AsnValues.val_vtx;
1156 CHECK_DECODE3(vtx, str_vtx, expected);
1159 //----------------------------------------------------
1161 var Asn_vis expected := AsnValues.blank_vis;
1162 CHECK_DECODE3(vis, str_vis0, expected);
1164 expected := AsnValues.val_vis;
1165 CHECK_DECODE3(vis, str_vis, expected);
1169 /************ The big, scary, unrestricted CHARACTER STRING ************/
1170 DECLARE_XER_ENCODERS(Asn_unr, unr);
1171 DECLARE_EXER_ENCODERS(Asn_unr,unr)
1173 const charstring str_unr_sxs :=
1175 "\t<identification>\n" &
1176 "\t\t<syntaxes>\n" &
1177 "\t\t\t<abstract>1.3.14.15.9.2.6.5.3.5.8.9.7.9.3.2.3.8.4.6.2.6.4.3.3</abstract>\n" &
1178 "\t\t\t<transfer>2.7.18.28.18.28.45.90.45</transfer>\n" &
1179 "\t\t</syntaxes>\n" &
1180 "\t</identification>\n" &
1181 "\t<string-value>C3A17276C3AD7A74C5B172C5912074C3</string-value>\n" &
1184 const charstring str_unr_sx :=
1186 "\t<identification>\n" &
1187 "\t\t<syntax>1.3.14.15.9.2.6.5.3.5.8.9.7.9.3.2.3.8.4.6.2.6.4.3.3</syntax>\n" &
1188 "\t</identification>\n" &
1189 "\t<string-value>BC6BC3B67266C3BA72C3B367C3A970</string-value>\n" &
1192 const charstring str_unr_pci :=
1194 "\t<identification>\n" &
1195 "\t\t<presentation-context-id>42</presentation-context-id>\n" &
1196 "\t</identification>\n" &
1197 "\t<string-value>C3815256C38D5A54C5B052C5902054C3</string-value>\n" &
1200 const charstring str_unr_cneg :=
1202 "\t<identification>\n" &
1203 "\t\t<context-negotiation>\n" &
1204 "\t\t\t<presentation-context-id>17</presentation-context-id>\n" &
1205 "\t\t\t<transfer-syntax>2.1.1</transfer-syntax>\n" &
1206 "\t\t</context-negotiation>\n" &
1207 "\t</identification>\n" &
1208 "\t<string-value>9C4BC3965246C39A52C39347C38950</string-value>\n" &
1211 const charstring str_unr_tsx :=
1213 "\t<identification>\n" &
1214 "\t\t<transfer-syntax>2.1.1</transfer-syntax>\n" &
1215 "\t</identification>\n" &
1216 "\t<string-value>BEEE</string-value>\n" &
1219 const charstring str_unr_fix :=
1221 "\t<identification>\n" &
1223 "\t</identification>\n" &
1224 "\t<string-value>" &
1225 "C3815256C38D5A54C5B052C5902054C39C4BC3965246C39A52C39347C38950" &
1226 "</string-value>\n" &
1229 testcase encode_unr() runs on ASN1
1231 var universal charstring expected;
1233 expected := str_unr_sxs; // syntaxes
1234 CHECK_METHOD(bxer_enc_unr, val_unr_sxs, expected);
1235 CHECK_METHOD(exer_enc_unr, val_unr_sxs, expected);
1237 CHECK_METHOD(cxer_enc_unr, val_unr_sxs, expected & lf);
1239 expected := str_unr_sx; // syntax
1240 CHECK_METHOD(bxer_enc_unr, val_unr_sx, expected);
1241 CHECK_METHOD(exer_enc_unr, val_unr_sx, expected);
1243 CHECK_METHOD(cxer_enc_unr, val_unr_sx, expected & lf);
1245 expected := str_unr_pci; // presentation-context-id
1246 CHECK_METHOD(bxer_enc_unr, val_unr_pci, expected);
1247 CHECK_METHOD(exer_enc_unr, val_unr_pci, expected);
1249 CHECK_METHOD(cxer_enc_unr, val_unr_pci, expected & lf);
1251 expected := str_unr_cneg; // context-negotiation
1252 CHECK_METHOD(bxer_enc_unr, val_unr_cneg, expected);
1253 CHECK_METHOD(exer_enc_unr, val_unr_cneg, expected);
1255 CHECK_METHOD(cxer_enc_unr, val_unr_cneg, expected & lf);
1257 expected := str_unr_tsx; // transfer-syntax
1258 CHECK_METHOD(bxer_enc_unr, val_unr_tsx, expected);
1259 CHECK_METHOD(exer_enc_unr, val_unr_tsx, expected);
1261 CHECK_METHOD(cxer_enc_unr, val_unr_tsx, expected & lf);
1264 expected := str_unr_fix; // fixed
1265 CHECK_METHOD(bxer_enc_unr, val_unr_fix, expected);
1266 CHECK_METHOD(exer_enc_unr, val_unr_fix, expected);
1268 CHECK_METHOD(cxer_enc_unr, val_unr_fix, expected & lf);
1271 testcase decode_unr() runs on ASN1
1273 var Asn_unr expected;
1275 expected := val_unr_sxs;
1276 CHECK_DECODE2(unr, str_unr_sxs, Asn_unr, expected);
1278 expected := val_unr_sx;
1279 CHECK_DECODE2(unr, str_unr_sx, Asn_unr, expected);
1281 expected := val_unr_pci;
1282 CHECK_DECODE2(unr, str_unr_pci, Asn_unr, expected);
1284 expected := val_unr_cneg;
1285 CHECK_DECODE2(unr, str_unr_cneg, Asn_unr, expected);
1287 expected := val_unr_tsx;
1288 CHECK_DECODE2(unr, str_unr_tsx, Asn_unr, expected);
1290 expected := val_unr_fix;
1291 CHECK_DECODE2(unr, str_unr_fix, Asn_unr, expected);
1296 /**************************** XXXX ****************************/
1297 DECLARE_XER_ENCODERS(LotsaText, softext);
1298 DECLARE_EXER_ENCODERS(LotsaText,softext)
1300 testcase limerick() runs on ASN1
1302 var LotsaText rval := AsnValues.limerick;
1303 var universal charstring expected :=
1305 "\t<VisibleString>There was a young fellow named Fisk</VisibleString>\n" &
1306 "\t<VisibleString>A swordsman, exceedingly brisk</VisibleString>\n" &
1307 "\t<VisibleString>So fast was his action</VisibleString>\n" &
1308 "\t<VisibleString>The Lorentz contraction</VisibleString>\n" &
1309 "\t<VisibleString>Reduced his rapier to a disc</VisibleString>\n" &
1311 CHECK_METHOD(bxer_enc_softext, rval, expected);
1312 CHECK_METHOD(exer_enc_softext, rval, expected);
1314 CHECK_METHOD(cxer_enc_softext, rval, expected & lf);
1321 /**************************** XXXX ****************************
1322 DECLARE_XER_ENCODERS(Asn_xxxx, xxxx);
1323 DECLARE_EXER_ENCODERS(Asn_xxxx,xxxx)
1325 testcase xxxx() runs on ASN1
1327 var Asn_xxxx rval := xXxX;
1328 var yyyy expected := "<XXXX>3.141593</XXXX>";
1329 CHECK_METHOD(cxer_enc_xxxx, rval, expected);
1330 CHECK_METHOD(bxer_enc_xxxx, rval, expected & lf);
1331 CHECK_METHOD(exer_enc_xxxx, rval, expected & lf);
1335 --------------- >8 --------------- cut here
1339 // An empty SEQUENCE
1340 DECLARE_XER_ENCODERS(NothingToSeeHere, nix);
1341 DECLARE_EXER_ENCODERS(NothingToSeeHere,nix)
1343 const universal charstring emptyelement := "<NothingToSeeHere/>\n";
1345 testcase encode_emptyrec() runs on ASN1
1348 CHECK_METHOD(cxer_enc_nix, AsnValues.move_along, emptyelement);
1349 CHECK_METHOD(bxer_enc_nix, AsnValues.move_along, emptyelement & lf);
1352 const universal charstring nonempty_element := "<NothingToSeeHere></NothingToSeeHere>\n";
1353 testcase decode_emptyrec() runs on ASN1
1355 CHECK_DECODE2(nix, emptyelement, NothingToSeeHere, AsnValues.move_along);
1356 // Use of the empty-element form is required for Canonical XER.
1357 // Basic XER should accept it.
1358 CHECK_DECODE(bxer_dec_nix, nonempty_element, NothingToSeeHere, AsnValues.move_along);
1361 /**************************** choice ****************************/
1362 DECLARE_XER_ENCODERS(Something, smth);
1363 DECLARE_EXER_ENCODERS(Something,smth)
1365 const charstring smth_bitstr :=
1367 "\t<bitstr>01001000100001</bitstr>\n" &
1370 const charstring smth_bool :=
1372 "\t<booool><true/></booool>\n" &
1375 const charstring smth_ebool :=
1377 "\t<booool>true</booool>\n" &
1380 const charstring smth_float :=
1382 "\t<floating>3.141593</floating>\n" &
1385 const charstring smth_barney :=
1387 "\t<cartoon><barney/></cartoon>\n" &
1390 const charstring smth_ebarney :=
1392 "\t<cartoon>barney</cartoon>\n" &
1395 const charstring smth_int :=
1397 "\t<wholenum>42</wholenum>\n" &
1401 testcase encode_something() runs on ASN1
1403 var universal charstring expected;
1405 var Something eval := { bitstr := '01001000100001'B }
1406 expected := smth_bitstr;
1407 CHECK_METHOD(bxer_enc_smth, eval, expected);
1408 CHECK_METHOD(exer_enc_smth, eval, expected);
1409 CHECK_METHOD(exer_enc_smth, eval, expected);
1411 CHECK_METHOD(cxer_enc_smth, eval, expected & lf);
1415 var Something eval := { booool := true }
1416 expected := smth_ebool;
1417 CHECK_METHOD(exer_enc_smth, eval, expected);
1418 expected := smth_bool;
1419 CHECK_METHOD(bxer_enc_smth, eval, expected);
1421 CHECK_METHOD(cxer_enc_smth, eval, expected & lf);
1425 var Something eval := { floating := 3.141593 };
1426 expected := smth_float;
1427 CHECK_METHOD(bxer_enc_smth, eval, expected);
1428 CHECK_METHOD(exer_enc_smth, eval, expected);
1429 CHECK_METHOD(exer_enc_smth, eval, expected);
1431 CHECK_METHOD(cxer_enc_smth, eval, expected & lf);
1435 var Something neval := { wholenum := 42 };
1436 expected := smth_int;
1437 CHECK_METHOD(bxer_enc_smth, neval, expected);
1438 CHECK_METHOD(exer_enc_smth, neval, expected);
1439 CHECK_METHOD(exer_enc_smth, neval, expected);
1441 CHECK_METHOD(cxer_enc_smth, neval, expected & lf);
1445 var Something feval := { cartoon := barney };
1446 expected := smth_ebarney;
1447 CHECK_METHOD(exer_enc_smth, feval, expected);
1448 expected := smth_barney;
1449 CHECK_METHOD(bxer_enc_smth, feval, expected);
1451 CHECK_METHOD(cxer_enc_smth, feval, expected & lf);
1455 testcase decode_something() runs on ASN1
1457 var Something expected;
1459 expected := { bitstr := '01001000100001'B };
1460 CHECK_DECODE2(smth, smth_bitstr, Something, expected);
1462 expected := { booool := true };
1463 CHECK_DECODE2(smth, smth_bool, Something, expected);
1465 expected := { floating := 3.141593 };
1466 CHECK_DECODE2(smth, smth_float, Something, expected);
1468 expected := { wholenum := 42 };
1469 CHECK_DECODE2(smth, smth_int, Something, expected);
1471 expected := { cartoon := barney };
1472 CHECK_DECODE2(smth, smth_barney, Something, expected);
1475 /**************************** record ****************************/
1477 DECLARE_XER_ENCODERS(Everything, ev);
1478 DECLARE_EXER_ENCODERS(Everything,ev)
1479 DECLARE_XER_ENCODERS(MaybeEverything, mev);
1480 DECLARE_EXER_ENCODERS(MaybeEverything,mev)
1482 const charstring xer_everything :=
1484 "\t<bitstr>01011010</bitstr>\n" &
1485 "\t<booool><true/></booool>\n" &
1488 "\t\t<identification>\n" &
1489 "\t\t\t<context-negotiation>\n" &
1490 "\t\t\t\t<presentation-context-id>69</presentation-context-id>\n" &
1491 "\t\t\t\t<transfer-syntax>2.7.18.28.18.28.45.90.45</transfer-syntax>\n" &
1492 "\t\t\t</context-negotiation>\n" &
1493 "\t\t</identification>\n" &
1494 "\t\t<data-value>C1AFB1</data-value>\n" &
1497 "\t<cartoon><wilma/></cartoon>\n" &
1500 "\t\t<direct-reference>2.1.1</direct-reference>\n" &
1501 "\t\t<indirect-reference>111</indirect-reference>\n" &
1502 "\t\t<data-value-descriptor>using context negotiation, both</data-value-descriptor>\n" &
1503 "\t\t<encoding>\n" &
1504 "\t\t\t<octet-aligned>1337D00D</octet-aligned>\n" &
1505 "\t\t</encoding>\n" &
1508 "\t<wholenum>1252</wholenum>\n" &
1511 "\t<objection>2.1.1</objection>\n" &
1512 "\t<octets>BAADF00D</octets>\n" &
1513 "\t<printer>evth</printer>\n" &
1514 "\t<floating>3.141593</floating>\n" &
1517 "\t<rroid>1.2.826.0.1249</rroid>\n" &
1519 "</Everything>\n\n";
1521 const charstring exer_everything :=
1523 "\t<bitstr>01011010</bitstr>\n" &
1524 "\t<booool>true</booool>\n" & // EXER uses TextBoolean
1527 "\t\t<identification>\n" &
1528 "\t\t\t<context-negotiation>\n" &
1529 "\t\t\t\t<presentation-context-id>69</presentation-context-id>\n" &
1530 "\t\t\t\t<transfer-syntax>2.7.18.28.18.28.45.90.45</transfer-syntax>\n" &
1531 "\t\t\t</context-negotiation>\n" &
1532 "\t\t</identification>\n" &
1533 "\t\t<data-value>C1AFB1</data-value>\n" &
1536 "\t<cartoon>wilma</cartoon>\n" & // EXER
1539 "\t\t<direct-reference>2.1.1</direct-reference>\n" &
1540 "\t\t<indirect-reference>111</indirect-reference>\n" &
1541 "\t\t<data-value-descriptor>using context negotiation, both</data-value-descriptor>\n" &
1542 "\t\t<encoding>\n" &
1543 "\t\t\t<octet-aligned>1337D00D</octet-aligned>\n" &
1544 "\t\t</encoding>\n" &
1547 "\t<wholenum>1252</wholenum>\n" &
1550 "\t<objection>2.1.1</objection>\n" &
1551 "\t<octets>BAADF00D</octets>\n" &
1552 "\t<printer>evth</printer>\n" &
1553 "\t<floating>3.141593</floating>\n" &
1556 "\t<rroid>1.2.826.0.1249</rroid>\n" &
1558 "</Everything>\n\n";
1560 const Everything evth := {
1561 bitstr := '01011010'B,
1563 pdv := AsnValues.pdv_cneg,
1565 outsider := AsnValues.ext_cn,
1569 objection:= AsnValues.ber_oid,
1570 octets := 'BAADF00D'O,
1572 floating := 3.141593,
1573 rroid := AsnValues.zoid
1577 testcase encode_everything() runs on ASN1
1579 var universal charstring expected;
1581 var Everything eval := evth;
1582 expected := xer_everything;
1583 CHECK_METHOD(bxer_enc_ev, eval, expected);
1585 CHECK_METHOD(cxer_enc_ev, eval, expected & lf);
1586 expected := exer_everything;
1587 CHECK_METHOD(exer_enc_ev, eval, expected);
1591 var Everything eval := AsnValues.a_evth;
1596 testcase decode_everything() runs on ASN1
1598 var Everything expected;
1600 CHECK_DECODE2(ev, xer_everything, Everything, expected);
1603 /*********************** record with optional fields ***********************/
1605 const charstring mevstr_all :=
1606 "<MaybeEverything>\n" &
1607 "\t<bitstr>01011010</bitstr>\n" &
1608 "\t<booool><true/></booool>\n" &
1611 "\t\t<identification>\n" &
1612 "\t\t\t<context-negotiation>\n" &
1613 "\t\t\t\t<presentation-context-id>69</presentation-context-id>\n" &
1614 "\t\t\t\t<transfer-syntax>2.7.18.28.18.28.45.90.45</transfer-syntax>\n" &
1615 "\t\t\t</context-negotiation>\n" &
1616 "\t\t</identification>\n" &
1617 "\t\t<data-value>C1AFB1</data-value>\n" &
1620 "\t<cartoon><betty/></cartoon>\n" &
1623 "\t\t<direct-reference>2.1.1</direct-reference>\n" &
1624 "\t\t<indirect-reference>111</indirect-reference>\n" &
1625 "\t\t<data-value-descriptor>using context negotiation, both</data-value-descriptor>\n" &
1626 "\t\t<encoding>\n" &
1627 "\t\t\t<octet-aligned>1337D00D</octet-aligned>\n" &
1628 "\t\t</encoding>\n" &
1631 "\t<wholenum>1252</wholenum>\n" &
1633 "\t<anyad>DECAFF</anyad>\n" &
1635 "\t<objection>2.1.1</objection>\n" &
1636 "\t<octets>BAADF00D</octets>\n" &
1637 "\t<printer>mev-all</printer>\n" &
1638 "\t<floating>3.141593</floating>\n" &
1639 "\t<rroid>1.2.826.0.1249</rroid>\n" &
1641 "</MaybeEverything>\n\n";
1643 const charstring mevstr_all_exer :=
1644 "<MaybeEverything>\n" &
1645 "\t<bitstr>01011010</bitstr>\n" &
1646 "\t<booool>true</booool>\n" & // EXER uses TextBooleean
1649 "\t\t<identification>\n" &
1650 "\t\t\t<context-negotiation>\n" &
1651 "\t\t\t\t<presentation-context-id>69</presentation-context-id>\n" &
1652 "\t\t\t\t<transfer-syntax>2.7.18.28.18.28.45.90.45</transfer-syntax>\n" &
1653 "\t\t\t</context-negotiation>\n" &
1654 "\t\t</identification>\n" &
1655 "\t\t<data-value>C1AFB1</data-value>\n" &
1658 "\t<cartoon>betty</cartoon>\n" & // EXER uses TextEnumerated
1661 "\t\t<direct-reference>2.1.1</direct-reference>\n" &
1662 "\t\t<indirect-reference>111</indirect-reference>\n" &
1663 "\t\t<data-value-descriptor>using context negotiation, both</data-value-descriptor>\n" &
1664 "\t\t<encoding>\n" &
1665 "\t\t\t<octet-aligned>1337D00D</octet-aligned>\n" &
1666 "\t\t</encoding>\n" &
1669 "\t<wholenum>1252</wholenum>\n" &
1671 "\t<anyad>DECAFF</anyad>\n" &
1673 "\t<objection>2.1.1</objection>\n" &
1674 "\t<octets>BAADF00D</octets>\n" &
1675 "\t<printer>mev-all</printer>\n" &
1676 "\t<floating>3.141593</floating>\n" &
1677 "\t<rroid>1.2.826.0.1249</rroid>\n" &
1679 "</MaybeEverything>\n\n";
1681 const MaybeEverything mev_all := {
1682 bitstr := '01011010'B,
1684 pdv := AsnValues.pdv_cneg,
1686 outsider := AsnValues.ext_cn,
1691 objection:= AsnValues.ber_oid,
1692 octets := 'BAADF00D'O,
1693 printer := "mev-all",
1694 floating := 3.141593,
1695 rroid := AsnValues.zoid
1698 const charstring mevstr_none := "<MaybeEverything/>\n\n";
1699 const MaybeEverything mev_none := {
1716 const charstring mevstr_bits :=
1717 "<MaybeEverything>\n" &
1718 "\t<bitstr>1010101001010101</bitstr>\n" &
1719 "</MaybeEverything>\n\n";
1721 const MaybeEverything mev_bits := {
1722 bitstr := '1010101001010101'B,
1738 const charstring mevstr_bitsbool :=
1739 "<MaybeEverything>\n" &
1740 "\t<bitstr>1010101001010101</bitstr>\n" &
1741 "\t<booool><false/></booool>\n" &
1742 "</MaybeEverything>\n\n";
1744 const charstring mevstr_bitsbool_exer :=
1745 "<MaybeEverything>\n" &
1746 "\t<bitstr>1010101001010101</bitstr>\n" &
1747 "\t<booool>false</booool>\n" & // EXER
1748 "</MaybeEverything>\n\n";
1750 const MaybeEverything mev_bitsbool := {
1751 bitstr := '1010101001010101'B,
1767 const charstring mevstr_3 :=
1768 "<MaybeEverything>\n" &
1769 "\t<bitstr>1010101001010101</bitstr>\n" &
1770 "\t<booool><false/></booool>\n" &
1771 "\t<cartoon><fred/></cartoon>\n" &
1772 "</MaybeEverything>\n\n";
1774 const charstring mevstr_3_exer :=
1775 "<MaybeEverything>\n" &
1776 "\t<bitstr>1010101001010101</bitstr>\n" &
1777 "\t<booool>false</booool>\n" & // EXER
1778 "\t<cartoon>fred</cartoon>\n" & // EXER
1779 "</MaybeEverything>\n\n";
1781 const MaybeEverything mev_3 := {
1782 bitstr := '1010101001010101'B,
1799 testcase encode_everything_opt() runs on ASN1
1801 var universal charstring expected;
1802 expected := mevstr_all;
1803 CHECK_METHOD(bxer_enc_mev, mev_all, expected);
1805 CHECK_METHOD(cxer_enc_mev, mev_all, expected & lf);
1806 expected := mevstr_all_exer;
1807 CHECK_METHOD(exer_enc_mev, mev_all, expected);
1809 expected := mevstr_none;
1810 CHECK_METHOD(bxer_enc_mev, mev_none, expected);
1811 CHECK_METHOD(exer_enc_mev, mev_none, expected);
1813 CHECK_METHOD(cxer_enc_mev, mev_none, expected & lf);
1815 expected := mevstr_bits;
1816 CHECK_METHOD(bxer_enc_mev, mev_bits, expected);
1817 CHECK_METHOD(exer_enc_mev, mev_bits, expected);
1819 CHECK_METHOD(cxer_enc_mev, mev_bits, expected & lf);
1821 expected := mevstr_bitsbool;
1822 CHECK_METHOD(bxer_enc_mev, mev_bitsbool, expected);
1824 CHECK_METHOD(cxer_enc_mev, mev_bitsbool, expected & lf);
1825 expected := mevstr_bitsbool_exer;
1826 CHECK_METHOD(exer_enc_mev, mev_bitsbool, expected);
1828 expected := mevstr_3;
1829 CHECK_METHOD(bxer_enc_mev, mev_3, expected);
1831 CHECK_METHOD(cxer_enc_mev, mev_3, expected & lf);
1832 expected := mevstr_3_exer;
1833 CHECK_METHOD(exer_enc_mev, mev_3, expected);
1836 testcase decode_everything_opt() runs on ASN1
1838 CHECK_DECODE2(mev, mevstr_all, MaybeEverything, mev_all);
1839 CHECK_DECODE2(mev, mevstr_none, MaybeEverything, mev_none);
1840 CHECK_DECODE2(mev, mevstr_bits, MaybeEverything, mev_bits);
1841 CHECK_DECODE2(mev, mevstr_bitsbool, MaybeEverything, mev_bitsbool);
1842 CHECK_DECODE2(mev, mevstr_3, MaybeEverything, mev_3);
1845 /**************************** enumerated ****************************/
1847 DECLARE_XER_ENCODERS(Flintstones, flin);
1848 DECLARE_EXER_ENCODERS(Flintstones,flin)
1850 const universal charstring fredstr_exer := "fred";
1851 const universal charstring barneystr_exer:= "barney";
1852 const universal charstring wilmastr_exer := "wilma";
1853 const universal charstring bettystr_exer := "betty";
1855 const universal charstring fredstr := "<" & fredstr_exer & "/>";
1856 const universal charstring barneystr:= "<" & barneystr_exer & "/>";
1857 const universal charstring wilmastr := "<" & wilmastr_exer & "/>";
1858 const universal charstring bettystr := "<" & bettystr_exer & "/>";
1860 const universal charstring fred_nested_exer := "<Flintstones>" & fredstr_exer & "</Flintstones>\n\n";
1861 const universal charstring barney_nested_exer:= "<Flintstones>" & barneystr_exer & "</Flintstones>\n\n";
1862 const universal charstring wilma_nested_exer := "<Flintstones>" & wilmastr_exer & "</Flintstones>\n\n";
1863 const universal charstring betty_nested_exer := "<Flintstones>" & bettystr_exer & "</Flintstones>\n\n";
1865 const universal charstring fred_nested := "<Flintstones>" & fredstr & "</Flintstones>\n";
1866 const universal charstring barney_nested:= "<Flintstones>" & barneystr & "</Flintstones>\n";
1867 const universal charstring wilma_nested := "<Flintstones>" & wilmastr & "</Flintstones>\n";
1868 const universal charstring betty_nested := "<Flintstones>" & bettystr & "</Flintstones>\n";
1870 testcase encode_flintstones() runs on ASN1
1872 CHECK_METHOD(bxer_enc_flin, fred, fred_nested & lf);
1873 CHECK_METHOD(exer_enc_flin, fred, fred_nested_exer);
1874 CHECK_METHOD(cxer_enc_flin, fred, fred_nested);
1876 CHECK_METHOD(bxer_enc_flin, barney, barney_nested & lf);
1877 CHECK_METHOD(exer_enc_flin, barney, barney_nested_exer);
1878 CHECK_METHOD(cxer_enc_flin, barney, barney_nested);
1880 CHECK_METHOD(bxer_enc_flin, wilma, wilma_nested & lf);
1881 CHECK_METHOD(exer_enc_flin, wilma, wilma_nested_exer);
1882 CHECK_METHOD(cxer_enc_flin, wilma, wilma_nested);
1884 CHECK_METHOD(bxer_enc_flin, betty, betty_nested & lf);
1885 CHECK_METHOD(exer_enc_flin, betty, betty_nested_exer);
1886 CHECK_METHOD(cxer_enc_flin, betty, betty_nested);
1890 testcase decode_flintstones() runs on ASN1
1892 var Flintstones expected;
1895 CHECK_DECODE2(flin, fred_nested, Flintstones, expected);
1898 CHECK_DECODE2(flin, barney_nested, Flintstones, expected);
1901 CHECK_DECODE2(flin, wilma_nested, Flintstones, expected);
1904 CHECK_DECODE2(flin, betty_nested, Flintstones, expected);
1907 /**************************** set of enumerated ****************************/
1909 DECLARE_XER_ENCODERS(Family, fam);
1910 DECLARE_EXER_ENCODERS(Family,fam)
1912 const universal charstring rubblestr :=
1913 "<Family>\n\t" & barneystr & bettystr & "\n</Family>\n\n";
1915 const universal charstring nobodystr :=
1918 const universal charstring allstr :=
1919 "<Family>\n\t" & fredstr & wilmastr & bettystr & barneystr & "\n</Family>\n\n";
1921 const universal charstring allstr_exer :=
1923 "\t<Flintstones>" & fredstr_exer & "</Flintstones>\n" &
1924 "\t<Flintstones>" & wilmastr_exer & "</Flintstones>\n" &
1925 "\t<Flintstones>" & bettystr_exer & "</Flintstones>\n" &
1926 "\t<Flintstones>" & barneystr_exer & "</Flintstones>\n" &
1929 const Family nobody := {}
1930 const Family alll := { fred, wilma, betty, barney }
1932 testcase encode_family() runs on ASN1
1934 //family rubble := { barney, betty }
1935 var universal charstring expected;
1937 expected := rubblestr;
1938 CHECK_METHOD(bxer_enc_fam, AsnValues.rubble, expected);
1940 CHECK_METHOD(cxer_enc_fam, AsnValues.rubble, expected & lf);
1942 expected := nobodystr;
1943 CHECK_METHOD(bxer_enc_fam, nobody, expected);
1944 CHECK_METHOD(exer_enc_fam, nobody, expected);
1946 CHECK_METHOD(cxer_enc_fam, nobody, expected & lf);
1949 CHECK_METHOD(bxer_enc_fam, alll, expected);
1951 CHECK_METHOD(cxer_enc_fam, alll, expected & lf);
1952 expected := allstr_exer;
1953 CHECK_METHOD(exer_enc_fam, alll, expected);
1956 testcase decode_family() runs on ASN1
1958 // suffix, input , type , expected
1959 CHECK_DECODE2(fam, rubblestr, Family, AsnValues.rubble);
1960 CHECK_DECODE2(fam, nobodystr, Family, nobody);
1961 CHECK_DECODE2(fam, allstr , Family, alll);
1964 const universal charstring nagy_arvizturo :=
1965 char(0,0,0,193) & "RV" & char(0,0,0,205) & "ZT" & char(0,0,1,112) & "R" &
1966 char(0,0,1,80) & " T" & char(0,0,0,220) & "K" & char(0,0,0,214) & "RF" &
1967 char(0,0,0,218) & "R" & char(0,0,0,211) & "G" & char(0,0,0,201) & "P";
1968 const universal charstring kis_arvizturo :=
1969 char(0,0,0,225) & "rv" & char(0,0,0,237) & "zt" & char(0,0,1,113) & "r" &
1970 char(0,0,1,81) & " t" & char(0,0,0,252) & "k" & char(0,0,0,246) & "rf" &
1971 char(0,0,0,250) & "r" & char(0,0,0,243) & "g" & char(0,0,0,233) & "p";
1974 //////////////////////////////////////////////////////////////////////////
1978 //////////////////////////////////////////////////////////////////////////
1981 execute(encode_bs());
1982 execute(encode_abool());
1983 execute(encode_pdv());
1984 execute(encode_ext());
1985 execute(encode_aint());
1986 execute(encode_nul());
1987 execute(encode_oid());
1988 execute(encode_roid());
1989 execute(encode_os());
1990 execute(encode_real());
1992 execute(encode_ia5str());
1993 execute(encode_utf());
1994 execute(encode_restricted_strings());
1996 execute(encode_unr());
1998 execute(encode_emptyrec());
1999 execute(encode_something());
2000 execute(encode_everything());
2001 execute(encode_everything_opt());
2003 execute(encode_flintstones());
2004 execute(encode_family());
2006 execute(limerick());
2008 execute(decode_bs());
2009 execute(decode_abool());
2010 execute(decode_pdv());
2011 execute(decode_ext());
2012 execute(decode_aint());
2013 execute(decode_nul());
2014 execute(decode_oid());
2015 execute(decode_roid());
2016 execute(decode_os());
2017 execute(decode_real());
2019 execute(decode_ia5str());
2020 execute(decode_utf());
2021 execute(decode_restricted_strings());
2023 execute(decode_unr());
2025 execute(decode_emptyrec());
2026 execute(decode_something());
2027 execute(decode_everything());
2028 execute(decode_everything_opt());
2030 execute(decode_flintstones());
2031 execute(decode_family());
2038 extension "version R8A";