Commit | Line | Data |
---|---|---|
970ed795 EL |
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 TtemplateEnum { | |
9 | type component templateEnum_mycomp {}; | |
10 | type enumerated templateEnum_myenum {xx1,xx2,xx3,xx4,xx5,xx6,xx7}; | |
11 | type record templateEnum_rec { | |
12 | templateEnum_myenum x1, | |
13 | templateEnum_myenum x2, | |
14 | templateEnum_myenum x3 optional }; | |
15 | template templateEnum_rec templateEnum_tSpec :={ //specific values | |
16 | x1:=xx1, | |
17 | x2:=xx2, | |
18 | x3:=xx3 }; | |
19 | template templateEnum_rec templateEnum_tList :={ //specific value and value list | |
20 | x1:=xx1, | |
21 | x2:=(xx2,xx3,xx6), | |
22 | x3:=xx3 }; | |
23 | template templateEnum_rec templateEnum_tComp :={ //specific value and compl. list | |
24 | x1:=xx1, | |
25 | x2:=complement (xx2,xx3,xx6), | |
26 | x3:=xx3 }; | |
27 | template templateEnum_rec templateEnum_tOmit :={ //omitting values | |
28 | x1:=xx1, | |
29 | x2:=xx2, | |
30 | x3:=omit } ; | |
31 | template templateEnum_rec templateEnum_tAny :={ //specific and any value | |
32 | x1:=xx1, | |
33 | x2:=xx2, | |
34 | x3:=? } ; | |
35 | template templateEnum_rec templateEnum_tAnyorNone :={ //specific and AnyorNone value | |
36 | x1:=xx1, | |
37 | x2:=xx2, | |
38 | x3:=* }; | |
39 | template templateEnum_rec templateEnum_tIfpresent :={ //specific value and ifpresent | |
40 | x1:=xx1, | |
41 | x2:=xx2, | |
42 | x3:=xx3 ifpresent }; | |
43 | ||
44 | testcase templateEnumSpec() runs on templateEnum_mycomp { | |
45 | var templateEnum_rec x1,x2; //specific value | |
46 | x1:={ x1:=xx1, x2:=xx2, x3:=xx3 }; | |
47 | x2:={ x1:=xx2, x2:=xx2, x3:=xx3 }; | |
48 | //match | |
49 | if (match(x1,templateEnum_tSpec)) {setverdict(pass);} | |
50 | else {setverdict(fail);} | |
51 | //no match | |
52 | if (not(match(x2,templateEnum_tSpec))) {setverdict(pass);} | |
53 | else {setverdict(fail);} | |
54 | } | |
55 | ||
56 | testcase templateEnumList() runs on templateEnum_mycomp { | |
57 | var templateEnum_rec x1,x2,x3; //value list | |
58 | x1:={ x1:=xx1, x2:=xx6, x3:=xx3 }; | |
59 | x2:={ x1:=xx1, x2:=xx7, x3:=xx3 }; | |
60 | x3:={ x1:=xx2, x2:=xx6, x3:=xx3 }; | |
61 | //match | |
62 | if (match(x1,templateEnum_tList)) {setverdict(pass);} | |
63 | else {setverdict(fail);} | |
64 | //no match: out of list | |
65 | if (not(match(x2,templateEnum_tList))) {setverdict(pass);} | |
66 | else {setverdict(fail);} | |
67 | //no match: other field | |
68 | if (not(match(x3,templateEnum_tList))) {setverdict(pass);} | |
69 | else {setverdict(fail);} | |
70 | } | |
71 | ||
72 | testcase templateEnumComp() runs on templateEnum_mycomp { | |
73 | var templateEnum_rec x1,x2,x3; //complemented list | |
74 | x1:={ x1:=xx1, x2:=xx7, x3:=xx3 }; | |
75 | x2:={ x1:=xx1, x2:=xx6, x3:=xx3 }; | |
76 | x3:={ x1:=xx2, x2:=xx7, x3:=xx3 }; | |
77 | //match | |
78 | if (match(x1,templateEnum_tComp)) {setverdict(pass);} | |
79 | else {setverdict(fail);} | |
80 | //no match: in the list | |
81 | if (not(match(x2,templateEnum_tComp))) {setverdict(pass);} | |
82 | else {setverdict(fail);} | |
83 | //no match: other field | |
84 | if (not(match(x3,templateEnum_tComp))) {setverdict(pass);} | |
85 | else {setverdict(fail);} | |
86 | } | |
87 | ||
88 | testcase templateEnumOmit() runs on templateEnum_mycomp { | |
89 | var templateEnum_rec x1,x2,x3; //omitting value | |
90 | x1:={ x1:=xx1, x2:=xx2, x3:=omit }; | |
91 | x2:={ x1:=xx1, x2:=xx2, x3:=xx3 }; | |
92 | x3:={ x1:=xx2, x2:=xx2, x3:=omit }; | |
93 | //match | |
94 | if (match(x1,templateEnum_tOmit)) {setverdict(pass);} | |
95 | else {setverdict(fail);} | |
96 | //no match: not omitted | |
97 | if (not(match(x2,templateEnum_tOmit))) {setverdict(pass);} | |
98 | else {setverdict(fail);} | |
99 | //no match: other field | |
100 | if (not(match(x3,templateEnum_tOmit))) {setverdict(pass);} | |
101 | else {setverdict(fail);} | |
102 | } | |
103 | ||
104 | testcase templateEnumAny() runs on templateEnum_mycomp { | |
105 | var templateEnum_rec x1,x2,x3; //any value | |
106 | x1:={ x1:=xx1, x2:=xx2, x3:=xx3 }; | |
107 | x2:={ x1:=xx2, x2:=xx2, x3:=xx3 }; | |
108 | x3:={ x1:=xx1, x2:=xx2, x3:=omit }; | |
109 | //match | |
110 | if (match(x1,templateEnum_tAny)) {setverdict(pass);} | |
111 | else {setverdict(fail);} | |
112 | //no match: field omitted | |
113 | if (not(match(x2,templateEnum_tAny))) {setverdict(pass);} | |
114 | else {setverdict(fail);} | |
115 | //no match: other field | |
116 | if (not(match(x3,templateEnum_tAny))) {setverdict(pass);} | |
117 | else {setverdict(fail);} | |
118 | } | |
119 | ||
120 | testcase templateEnumAnyorNone() runs on templateEnum_mycomp { | |
121 | var templateEnum_rec x1,x2,x3; //AnyorNone value | |
122 | x1:={ x1:=xx1, x2:=xx2, x3:=omit }; | |
123 | x2:={ x1:=xx1, x2:=xx2, x3:=xx3 }; | |
124 | x3:={ x1:=xx2, x2:=xx2, x3:=omit }; | |
125 | //match: omitted | |
126 | if (match(x1,templateEnum_tAnyorNone)) {setverdict(pass);} | |
127 | else {setverdict(fail);} | |
128 | //match: value | |
129 | if (match(x2,templateEnum_tAnyorNone)) {setverdict(pass);} | |
130 | else {setverdict(fail);} | |
131 | //no match: other field | |
132 | if (not(match(x3,templateEnum_tAnyorNone))) {setverdict(pass);} | |
133 | else {setverdict(fail);} | |
134 | } | |
135 | ||
136 | testcase templateEnumIfpresent() runs on templateEnum_mycomp { | |
137 | var templateEnum_rec x1,x2,x3,x4; //ifpresent | |
138 | x1:={ x1:=xx1, x2:=xx2, x3:=xx3 }; | |
139 | x2:={ x1:=xx1, x2:=xx2, x3:=omit }; | |
140 | x3:={ x1:=xx2, x2:=xx2, x3:=omit }; | |
141 | x4:={ x1:=xx1, x2:=xx2, x3:=xx4 }; | |
142 | //match: present and match | |
143 | if (match(x1,templateEnum_tIfpresent)) {setverdict(pass);} | |
144 | else {setverdict(fail);} | |
145 | //match: not present | |
146 | if (match(x2,templateEnum_tIfpresent)) {setverdict(pass);} | |
147 | else {setverdict(fail);} | |
148 | //no match: present and not match | |
149 | if (not(match(x3,templateEnum_tIfpresent))) {setverdict(pass);} | |
150 | else {setverdict(fail);} | |
151 | //no match: other field | |
152 | if (not(match(x4,templateEnum_tIfpresent))) {setverdict(pass);} | |
153 | else {setverdict(fail);} | |
154 | } | |
155 | ||
156 | control { | |
157 | execute(templateEnumSpec()); | |
158 | execute(templateEnumList()); | |
159 | execute(templateEnumComp()); | |
160 | execute(templateEnumOmit()); | |
161 | execute(templateEnumAny()); | |
162 | execute(templateEnumAnyorNone()); | |
163 | execute(templateEnumIfpresent()); | |
164 | } | |
165 | } |