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