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
|
/******************************************************************************
* Copyright (c) 2000-2016 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Balasko, Jeno
* Raduly, Csaba
*
******************************************************************************/
module DFEAttribTest {
modulepar boolean DFEAttribTest_verbose := false;
#define verbose DFEAttribTest_verbose
#include "../macros.ttcnin"
type component DFEA {}
/******** boolean *********/
type record dfeabool {
boolean b
}
with {
variant (b) "defaultForEmpty as 'true'";
variant (b) "attribute"
}
DECLARE_EXER_ENCODERS(dfeabool, dfeb);
const dfeabool yea := { true }
const universal charstring estr_yea :=
"<dfeabool b='true'/>\n\n";
const universal charstring estr_yea_omit :=
"<dfeabool />\n\n";
const dfeabool nay := { false }
const universal charstring estr_nay :=
"<dfeabool b='false'/>\n\n";
testcase encode_dfeabool() runs on DFEA
{
CHECK_METHOD(exer_enc_dfeb, yea, estr_yea);
CHECK_METHOD(exer_enc_dfeb, nay, estr_nay);
}
testcase decode_dfeabool() runs on DFEA
{
CHECK_DECODE(exer_dec_dfeb, estr_yea, dfeabool, yea);
CHECK_DECODE(exer_dec_dfeb, estr_yea_omit, dfeabool, yea);
CHECK_DECODE(exer_dec_dfeb, estr_nay, dfeabool, nay);
}
/******** charstring *********/
type record dfecs {
charstring cs
}
with {
variant (cs) "defaultForEmpty as 'supercalifragilistic'"; // expialidocious
variant (cs) "attribute"
}
DECLARE_EXER_ENCODERS(dfecs, dfecs);
const dfecs expi := { "expialidocious" }
const universal charstring estr_expi :=
"<dfecs cs='expialidocious'/>\n\n"
const dfecs super := { "supercalifragilistic" }
const universal charstring estr_super :=
"<dfecs cs='supercalifragilistic'/>\n\n"
const universal charstring estr_super0 :=
"<dfecs/>"
testcase encode_dfecs() runs on DFEA
{
CHECK_METHOD(exer_enc_dfecs, expi , estr_expi);
CHECK_METHOD(exer_enc_dfecs, super, estr_super);
}
testcase decode_dfecs() runs on DFEA
{
CHECK_DECODE(exer_dec_dfecs, estr_expi , dfecs, expi);
CHECK_DECODE(exer_dec_dfecs, estr_super , dfecs, super);
CHECK_DECODE(exer_dec_dfecs, estr_super0, dfecs, super);
}
/********** float **********/
type record dfeaf {
float f
}
with {
variant (f) "defaultForEmpty as '2.71828'";
variant (f) "attribute"
}
DECLARE_EXER_ENCODERS(dfeaf, dfeaf);
const dfeaf pi := { 3.141592 } // close enough
const universal charstring estr_pi :=
"<dfeaf f='3.141592'/>\n\n";
const dfeaf ee := { 2.71828 }
const universal charstring estr_ee :=
"<dfeaf f='2.718280'/>\n\n";
const universal charstring estr_ee0 :=
"<dfeaf/>\n\n";
testcase encode_dfeaf() runs on DFEA
{
CHECK_METHOD(exer_enc_dfeaf, pi, estr_pi);
CHECK_METHOD(exer_enc_dfeaf, ee, estr_ee);
}
testcase decode_dfeaf() runs on DFEA
{
CHECK_DECODE(exer_dec_dfeaf, estr_pi , dfeaf, pi);
CHECK_DECODE(exer_dec_dfeaf, estr_ee , dfeaf, ee);
CHECK_DECODE(exer_dec_dfeaf, estr_ee0, dfeaf, ee);
}
/********** integer **********/
type record dfeaint {
integer i
}
with {
variant (i) "defaultForEmpty as '147'";
variant (i) "attribute"
}
DECLARE_EXER_ENCODERS(dfeaint, dfei);
const dfeaint fourty_two := { 42 };
const universal charstring estr_42 :=
"<dfeaint i='42'/>\n\n";
const dfeaint one_four_seven := { 147 };
const universal charstring estr_147 :=
"<dfeaint i='147'/>\n\n";
const universal charstring estr_147o :=
"<dfeaint/>";
testcase encode_dfei() runs on DFEA
{
CHECK_METHOD(exer_enc_dfei, fourty_two, estr_42);
CHECK_METHOD(exer_enc_dfei, one_four_seven, estr_147);
}
testcase decode_dfei() runs on DFEA
{
CHECK_DECODE(exer_dec_dfei, estr_42 , dfeaint, fourty_two);
CHECK_DECODE(exer_dec_dfei, estr_147 , dfeaint, one_four_seven);
CHECK_DECODE(exer_dec_dfei, estr_147o, dfeaint, one_four_seven);
}
/********** uni-str **********/
type record dfeus {
universal charstring us
}
with {
variant (us) "defaultForEmpty as 'Supercalifragilistic'"; // expialidocious
variant (us) "attribute"
}
DECLARE_EXER_ENCODERS(dfeus, dfeus);
const dfeus uexpi := { "Expialidocious" }
const universal charstring eustr_expi :=
"<dfeus us='Expialidocious'/>\n\n"
const dfeus usuper := { "Supercalifragilistic" }
const universal charstring eustr_super :=
"<dfeus us='Supercalifragilistic'/>\n\n"
const universal charstring eustr_super0 :=
"<dfeus/>"
testcase encode_dfeus() runs on DFEA
{
CHECK_METHOD(exer_enc_dfeus, uexpi , eustr_expi);
CHECK_METHOD(exer_enc_dfeus, usuper, eustr_super);
}
testcase decode_dfeus() runs on DFEA
{
CHECK_DECODE(exer_dec_dfeus, eustr_expi , dfeus, uexpi);
CHECK_DECODE(exer_dec_dfeus, eustr_super , dfeus, usuper);
CHECK_DECODE(exer_dec_dfeus, eustr_super0, dfeus, usuper);
}
/**********************************************************************/
testcase stopper() runs on DFEA // never in control
{
NOT_YET
}
control {
execute(encode_dfeabool());
execute(decode_dfeabool());
execute(encode_dfecs());
execute(decode_dfecs());
execute(encode_dfeaf());
execute(decode_dfeaf());
execute(encode_dfeus());
execute(decode_dfeus());
}
}
with {
encode "XML";
}
|