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 module DefaultForEmpty {
9 modulepar boolean DefaultForEmpty_verbose := false;
10 #define verbose DefaultForEmpty_verbose
11 #include "../macros.ttcnin"
15 type record DFEProduct {
22 variant (color) "attribute";
23 variant (currency) "defaultForEmpty as 'US Dollars'";
28 DECLARE_XER_ENCODERS(DFEProduct, dfe);
29 DECLARE_EXER_ENCODERS(DFEProduct, dfe);
31 const DFEProduct dfeval := {
35 currency := "US Dollars"
38 const universal charstring str_dfe_e_enc := // encoding, not omitted
39 "<DFEProduct color=\'red\'>\n" &
40 "\t<name>shirt</name>\n" &
41 "\t<price>12.330000</price>\n" &
42 "\t<currency>US Dollars</currency>\n" &
46 const universal charstring str_dfe_e_dec := // decoding, omitted
47 "<DFEProduct color=\'red\'>\n" &
48 "\t<name>shirt</name>\n" &
49 "\t<price>12.330000</price>\n" &
54 const universal charstring str_dfe_b :=
56 "\t<color>red</color>\n" &
57 "\t<name>shirt</name>\n" &
58 "\t<price>12.330000</price>\n" &
59 "\t<currency>US Dollars</currency>\n" &
63 testcase encode_dfe() runs on DFE
65 CHECK_METHOD(bxer_enc_dfe, dfeval, str_dfe_b);
66 CHECK_METHOD(exer_enc_dfe, dfeval, str_dfe_e_enc);
69 testcase decode_dfe() runs on DFE
71 CHECK_DECODE(bxer_dec_dfe, str_dfe_b, DFEProduct, dfeval);
72 // Decoding must handle both forms
73 CHECK_DECODE(exer_dec_dfe, str_dfe_e_enc, DFEProduct, dfeval);
74 CHECK_DECODE(exer_dec_dfe, str_dfe_e_dec, DFEProduct, dfeval);
78 execute(encode_dfe());
79 execute(decode_dfe());