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
13 * Szabo, Janos Zoltan – initial implementation
15 ******************************************************************************/
16 module TtemplateUnion {
17 type component templateUnion_mycomp {};
18 type union templateUnion_myunion {
21 type record templateUnion_rec {
22 templateUnion_myunion x1,
23 templateUnion_myunion x2,
24 templateUnion_myunion x3 optional };
25 template templateUnion_rec templateUnion_tSpec :={ //specific values
29 template templateUnion_rec templateUnion_tList :={ //specific value and value list
31 x2:=({f1:=2},{f1:=3},{f2:=1.2}),
33 template templateUnion_rec templateUnion_tComp :={ //specific value and compl. list
35 x2:=complement ({f1:=2},{f2:=1.2},{f1:=6}),
37 template templateUnion_rec templateUnion_tOmit :={ //omitting values
41 template templateUnion_rec templateUnion_tAny :={ //specific and any value
45 template templateUnion_rec templateUnion_tAnyorNone :={ //specific and AnyorNone value
49 //template templateUnion_rec templateUnion_tIfpresent :={ //specific value and ifpresent
52 // x3:={f1:=3} ifpresent };
54 testcase templateUnionSpec() runs on templateUnion_mycomp {
55 var templateUnion_myunion temp:={f1:=3};
56 var templateUnion_rec x1,x2; //specific value
57 x1:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=temp };
58 x2:={ x1:={f2:=1.3}, x2:={f1:=2}, x3:=temp };
60 if (match(x1,templateUnion_tSpec)) {setverdict(pass);}
61 else {setverdict(fail);}
63 if (not(match(x2,templateUnion_tSpec))) {setverdict(pass);}
64 else {setverdict(fail);}
67 testcase templateUnionList() runs on templateUnion_mycomp {
68 var templateUnion_myunion temp:={f1:=3};
69 var templateUnion_rec x1,x2,x3; //value list
70 x1:={ x1:={f2:=1.2}, x2:={f1:=3}, x3:=temp };
71 x2:={ x1:={f2:=1.2}, x2:={f1:=7}, x3:=temp };
72 x3:={ x1:={f1:=8}, x2:={f1:=3}, x3:=temp };
74 if (match(x1,templateUnion_tList)) {setverdict(pass);}
75 else {setverdict(fail);}
76 //no match: out of list
77 if (not(match(x2,templateUnion_tList))) {setverdict(pass);}
78 else {setverdict(fail);}
79 //no match: other field
80 if (not(match(x3,templateUnion_tList))) {setverdict(pass);}
81 else {setverdict(fail);}
84 testcase templateUnionComp() runs on templateUnion_mycomp {
85 var templateUnion_myunion temp:={f1:=3};
86 var templateUnion_rec x1,x2,x3; //complemented list
87 x1:={ x1:={f2:=1.2}, x2:={f1:=7}, x3:=temp };
88 x2:={ x1:={f2:=1.2}, x2:={f1:=6}, x3:=temp };
89 x3:={ x1:={f2:=1.3}, x2:={f1:=7}, x3:=temp };
91 if (match(x1,templateUnion_tComp)) {setverdict(pass);}
92 else {setverdict(fail);}
93 //no match: in the list
94 if (not(match(x2,templateUnion_tComp))) {setverdict(pass);}
95 else {setverdict(fail);}
96 //no match: other field
97 if (not(match(x3,templateUnion_tComp))) {setverdict(pass);}
98 else {setverdict(fail);}
101 testcase templateUnionOmit() runs on templateUnion_mycomp {
102 var templateUnion_myunion temp:={f1:=3};
103 var templateUnion_rec x1,x2,x3; //omitting value
104 x1:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=omit };
105 x2:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=temp };
106 x3:={ x1:={f1:=2}, x2:={f1:=2}, x3:=omit };
108 if (match(x1,templateUnion_tOmit)) {setverdict(pass);}
109 else {setverdict(fail);}
110 //no match: not omitted
111 if (not(match(x2,templateUnion_tOmit))) {setverdict(pass);}
112 else {setverdict(fail);}
113 //no match: other field
114 if (not(match(x3,templateUnion_tOmit))) {setverdict(pass);}
115 else {setverdict(fail);}
118 testcase templateUnionAny() runs on templateUnion_mycomp {
119 var templateUnion_myunion temp:={f1:=3};
120 var templateUnion_rec x1,x2,x3; //any value
121 x1:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=temp };
122 x2:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=omit };
123 x3:={ x1:={f1:=2}, x2:={f1:=2}, x3:=temp };
125 if (match(x1,templateUnion_tAny)) {setverdict(pass);}
126 else {setverdict(fail);}
127 //no match: field omitted
128 if (not(match(x2,templateUnion_tAny))) {setverdict(pass);}
129 else {setverdict(fail);}
130 //no match: other field
131 if (not(match(x3,templateUnion_tAny))) {setverdict(pass);}
132 else {setverdict(fail);}
135 testcase templateUnionAnyorNone() runs on templateUnion_mycomp {
136 var templateUnion_myunion temp:={f1:=3};
137 var templateUnion_rec x1,x2,x3; //AnyorNone value
138 x1:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=omit };
139 x2:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=temp };
140 x3:={ x1:={f1:=2}, x2:={f1:=2}, x3:=omit };
142 if (match(x1,templateUnion_tAnyorNone)) {setverdict(pass);}
143 else {setverdict(fail);}
145 if (match(x2,templateUnion_tAnyorNone)) {setverdict(pass);}
146 else {setverdict(fail);}
147 //no match: other field
148 if (not(match(x3,templateUnion_tAnyorNone))) {setverdict(pass);}
149 else {setverdict(fail);}
152 //testcase templateUnionIfpresent() runs on templateInt_mycomp {
153 //var templateUnion_myunion temp1:={f1:=3}; //ifpresent
154 //var templateUnion_myunion temp2:={f1:=4};
155 //var templateUnion_rec x1,x2,x3,x4;
156 //x1:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=temp1 };
157 //x2:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=omit };
158 //x3:={ x1:={f2:=1.2}, x2:={f1:=2}, x3:=temp2 };
159 //x4:={ x1:={f2:=1.4}, x2:={f1:=2}, x3:=omit };
160 //match: present and match
161 //if (match(x1,templateUnion_tIfpresent)) {setverdict(pass);}
162 // else {setverdict(fail);}
164 //if (match(x2,templateUnion_tIfpresent)) {setverdict(pass);}
165 // else {setverdict(fail);}
166 //no match: present and not match
167 //if (not(match(x3,templateUnion_tIfpresent))) {setverdict(pass);}
168 // else {setverdict(fail);}
169 //no match: other field
170 //if (not(match(x4,templateUnion_tIfpresent))) {setverdict(pass);}
171 // else {setverdict(fail);}
181 type record of charstring ROC;
182 type record of integer ROI;
183 type record MyRecord1 {
189 type union MyUnion1 {
196 testcase tc_record_withWildCard3E() runs on templateUnion_mycomp {
197 var template MyRec2 vtl_rec2;
199 //log("The value of the record:",vtl_rec2.u);
200 if(ispresent(vtl_rec2.u.i)){setverdict(fail)}else {setverdict(pass)};
204 execute(templateUnionSpec());
205 execute(templateUnionList());
206 execute(templateUnionComp());
207 execute(templateUnionOmit());
208 execute(templateUnionAny());
209 execute(templateUnionAnyorNone());
210 // execute(templateUnionIfpresent());
211 execute(tc_record_withWildCard3E());