Sync with 5.4.1
[deliverable/titan.core.git] / regression_test / XML / EXER-whitepaper / DefaultForEmpty.ttcnpp
1 /******************************************************************************
2 * Copyright (c) 2000-2015 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"
12
13 type component DFE {}
14
15 type record DFEProduct {
16 charstring color,
17 charstring name,
18 float price,
19 charstring currency
20 }
21 with {
22 variant (color) "attribute";
23 variant (currency) "defaultForEmpty as 'US Dollars'";
24 }
25
26
27
28 DECLARE_XER_ENCODERS(DFEProduct, dfe);
29 DECLARE_EXER_ENCODERS(DFEProduct, dfe);
30
31 const DFEProduct dfeval := {
32 color := "red",
33 name := "shirt",
34 price := 12.33,
35 currency := "US Dollars"
36 }
37
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" &
43 "</DFEProduct>\n" &
44 "\n";
45
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" &
50 "\t<currency/>\n" &
51 "</DFEProduct>\n" &
52 "\n";
53
54 const universal charstring str_dfe_b :=
55 "<DFEProduct>\n" &
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" &
60 "</DFEProduct>\n" &
61 "\n";
62
63 testcase encode_dfe() runs on DFE
64 {
65 CHECK_METHOD(bxer_enc_dfe, dfeval, str_dfe_b);
66 CHECK_METHOD(exer_enc_dfe, dfeval, str_dfe_e_enc);
67 }
68
69 testcase decode_dfe() runs on DFE
70 {
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);
75 }
76
77 control {
78 execute(encode_dfe());
79 execute(decode_dfe());
80 }
81
82 }
83 with {
84 encode "XML"
85 }
This page took 0.034218 seconds and 5 git commands to generate.