Last sync 2016.04.01
[deliverable/titan.core.git] / regression_test / templateBool / TtemplateBool.ttcn
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
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Raduly, Csaba
11 * Szabados, Kristof
12 * Szabo, Janos Zoltan – initial implementation
13 *
14 ******************************************************************************/
15 module TtemplateBool {
16 type component templateBool_mycomp {};
17 type record templateBool_rec {
18 boolean x1,
19 boolean x2,
20 boolean x3 optional };
21 template templateBool_rec templateBool_tSpec :={ //specific values
22 x1:=true,
23 x2:=false,
24 x3:=false };
25 template templateBool_rec templateBool_tList :={ //specific value and value list
26 x1:=true,
27 x2:=(false),
28 x3:=false };
29 template templateBool_rec templateBool_tComp :={ //specific value and compl. list
30 x1:=true,
31 x2:=complement (true),
32 x3:=false };
33 template templateBool_rec templateBool_tOmit :={ //omitting values
34 x1:=true,
35 x2:=false,
36 x3:=omit } ;
37 template templateBool_rec templateBool_tAny :={ //specific and any value
38 x1:=true,
39 x2:=false,
40 x3:=? } ;
41 template templateBool_rec templateBool_tAnyorNone :={ //specific and AnyorNone value
42 x1:=true,
43 x2:=false,
44 x3:=* };
45 template templateBool_rec templateBool_tIfpresent :={ //specific value and ifpresent
46 x1:=true,
47 x2:=false,
48 x3:=false ifpresent };
49
50 testcase templateBoolSpec() runs on templateBool_mycomp {
51 var templateBool_rec x1,x2; //specific value
52 x1:={ x1:=true, x2:=false, x3:=false };
53 x2:={ x1:=true, x2:=true, x3:=false };
54 //match
55 if (match(x1,templateBool_tSpec)) {setverdict(pass);}
56 else {setverdict(fail);}
57 //no match
58 if (not(match(x2,templateBool_tSpec))) {setverdict(pass);}
59 else {setverdict(fail);}
60 }
61
62 testcase templateBoolList() runs on templateBool_mycomp {
63 var templateBool_rec x1,x2,x3; //value list
64 x1:={ x1:=true, x2:=false, x3:=false };
65 x2:={ x1:=true, x2:=true, x3:=false };
66 x3:={ x1:=false, x2:=false, x3:=false };
67 //match
68 if (match(x1,templateBool_tList)) {setverdict(pass);}
69 else {setverdict(fail);}
70 //no match: out of list
71 if (not(match(x2,templateBool_tList))) {setverdict(pass);}
72 else {setverdict(fail);}
73 //no match: other field
74 if (not(match(x3,templateBool_tList))) {setverdict(pass);}
75 else {setverdict(fail);}
76 }
77
78 testcase templateBoolComp() runs on templateBool_mycomp {
79 var templateBool_rec x1,x2,x3; //complemented list
80 x1:={ x1:=true, x2:=false, x3:=false };
81 x2:={ x1:=true, x2:=true, x3:=false };
82 x3:={ x1:=false, x2:=false, x3:=false };
83 //match
84 if (match(x1,templateBool_tComp)) {setverdict(pass);}
85 else {setverdict(fail);}
86 //no match: in the list
87 if (not(match(x2,templateBool_tComp))) {setverdict(pass);}
88 else {setverdict(fail);}
89 //no match: other field
90 if (not(match(x3,templateBool_tComp))) {setverdict(pass);}
91 else {setverdict(fail);}
92 }
93
94 testcase templateBoolOmit() runs on templateBool_mycomp {
95 var templateBool_rec x1,x2,x3; //omitting value
96 x1:={ x1:=true, x2:=false, x3:=omit };
97 x2:={ x1:=true, x2:=false, x3:=true };
98 x3:={ x1:=false, x2:=false, x3:=omit };
99 //match
100 if (match(x1,templateBool_tOmit)) {setverdict(pass);}
101 else {setverdict(fail);}
102 //no match: not omitted
103 if (not(match(x2,templateBool_tOmit))) {setverdict(pass);}
104 else {setverdict(fail);}
105 //no match: other field
106 if (not(match(x3,templateBool_tOmit))) {setverdict(pass);}
107 else {setverdict(fail);}
108 }
109
110 testcase templateBoolAny() runs on templateBool_mycomp {
111 var templateBool_rec x1,x2,x3; //any value
112 x1:={ x1:=true, x2:=false, x3:=false };
113 x2:={ x1:=true, x2:=false, x3:=omit };
114 x3:={ x1:=false, x2:=false, x3:=false };
115 //match
116 if (match(x1,templateBool_tAny)) {setverdict(pass);}
117 else {setverdict(fail);}
118 //no match: field omitted
119 if (not(match(x2,templateBool_tAny))) {setverdict(pass);}
120 else {setverdict(fail);}
121 //no match: other field
122 if (not(match(x3,templateBool_tAny))) {setverdict(pass);}
123 else {setverdict(fail);}
124 }
125
126 testcase templateBoolAnyorNone() runs on templateBool_mycomp {
127 var templateBool_rec x1,x2,x3; //AnyorNone value
128 x1:={ x1:=true, x2:=false, x3:=omit };
129 x2:={ x1:=true, x2:=false, x3:=true };
130 x3:={ x1:=false, x2:=false, x3:=omit };
131 //match: omitted
132 if (match(x1,templateBool_tAnyorNone)) {setverdict(pass);}
133 else {setverdict(fail);}
134 //match: value
135 if (match(x2,templateBool_tAnyorNone)) {setverdict(pass);}
136 else {setverdict(fail);}
137 //no match: other field
138 if (not(match(x3,templateBool_tAnyorNone))) {setverdict(pass);}
139 else {setverdict(fail);}
140 }
141
142 testcase templateBoolIfpresent() runs on templateBool_mycomp {
143 var templateBool_rec x1,x2,x3,x4; //ifpresent
144 x1:={ x1:=true, x2:=false, x3:=false };
145 x2:={ x1:=true, x2:=false, x3:=omit };
146 x3:={ x1:=true, x2:=false, x3:=true };
147 x4:={ x1:=false, x2:=false, x3:=omit };
148 //match: present and match
149 if (match(x1,templateBool_tIfpresent)) {setverdict(pass);}
150 else {setverdict(fail);}
151 //match: not present
152 if (match(x2,templateBool_tIfpresent)) {setverdict(pass);}
153 else {setverdict(fail);}
154 //no match: present and not match
155 if (not(match(x3,templateBool_tIfpresent))) {setverdict(pass);}
156 else {setverdict(fail);}
157 //no match: other field
158 if (not(match(x4,templateBool_tIfpresent))) {setverdict(pass);}
159 else {setverdict(fail);}
160 }
161
162 control {
163 execute(templateBoolSpec());
164 execute(templateBoolList());
165 execute(templateBoolComp());
166 execute(templateBoolOmit());
167 execute(templateBoolAny());
168 execute(templateBoolAnyorNone());
169 execute(templateBoolIfpresent());
170
171 }
172 }
This page took 0.043211 seconds and 5 git commands to generate.