3162a342a5266709e790f683203b160d0d011c1b
[smo/teiv.git] /
1 module typedef-test-restrictions-module {
2
3         namespace "test:typedef-test-restrictions-module";
4         prefix "this";
5
6         description
7         "Copyright (C) 2024 Ericsson
8         Modifications Copyright (C) 2024 OpenInfra Foundation Europe";
9
10         revision "2020-11-11" {
11                 description "initial revision";
12         }
13
14         typedef typedef1 {
15                 type string {
16                         length 10..20;
17                         pattern "ab*c";
18                 }
19                 default "Hello";
20         }
21
22         typedef typedef2 {
23                 type int32 {
24                         range 30..40;
25                 }
26                 default 35;
27         }
28
29         typedef typedef3 {
30                 type enumeration {
31                         enum zero {
32                                 value 10;
33                         }
34                         enum one {
35                                 value 11;
36                         }
37                         enum two {
38                                 value 12;
39                         }
40                 }
41                 default one;
42         }
43
44         typedef typedef4 {
45                 type bits {
46                         bit four {
47                                 position 16;
48                         }
49                         bit five {
50                                 position 17;
51                         }
52                         bit six {
53                                 position 18;
54                         }
55                 }
56         }
57
58 // - - - - - - no changes - - - - - -
59
60         container cont1 {
61                 leaf leaf1 {
62                         type this:typedef1;
63                 }
64                 leaf leaf2 {
65                         type this:typedef2;
66                 }
67                 leaf leaf3 {
68                         type this:typedef3;
69                 }
70                 leaf leaf4 {
71                         type this:typedef4;
72                 }
73         }
74
75 // - - - - - - some overrides - - - - - -
76
77         container cont2 {
78
79                 leaf leaf7 {
80                         type this:typedef1 {
81                                 length 12..15;
82                                 pattern "de*f";
83                         }
84                         default "World";
85                 }
86
87                 leaf leaf8 {
88                         type this:typedef2 {
89                                 range 30..35;
90                         }
91                         default 32;
92                 }
93
94                 leaf leaf9 {
95                         type this:typedef3 {
96                                 enum zero {
97                                         value 10;
98                                 }
99                                 enum one;
100                         }
101                         default zero;
102                 }
103
104                 leaf leaf10 {
105                         type this:typedef4 {
106                                 bit five;
107                                 bit six {
108                                         position 18;
109                                 }
110                         }
111                         default six;
112                 }
113         }
114
115 // - - - - - - some multi-level overrides - - - - - -
116
117         typedef typedef13 {
118                 type typedef1 {
119                         length 5..8;
120                         pattern "gh*i";
121                         pattern "mn*o";
122                 }
123         }
124
125         typedef typedef14 {
126                 type typedef2 {
127                         range 15..18;
128                 }
129                 default 20;
130         }
131
132         typedef typedef15 {
133                 type this:typedef3 {
134                         enum zero;
135                         enum one;
136                 }
137                 default one;
138         }
139
140         container cont3 {
141
142                 leaf leaf18 {
143                         type this:typedef13 {
144                                 length 6..7;
145                         }
146                         default "Moon";
147                 }
148
149                 leaf leaf19 {
150                         type this:typedef14 {
151                                 range 16..17;
152                         }
153                         default 13;
154                 }
155
156                 leaf leaf20 {
157                         type this:typedef15 {
158                                 enum one;
159                         }
160                 }
161         }
162
163 // - - - - - - some illegal statements for restriction - - - - - -
164
165         container cont4 {
166
167                 leaf leaf28 {
168                         type this:typedef1 {
169                                 range 12..15;           // Wrong, it's a string
170                                 enum one;                       // Wrong, it's a string
171                         }
172                 }
173
174                 leaf leaf29 {
175                         type this:typedef2 {
176                                 length 12..15;          // Wrong, it's a numeric type
177                                 pattern "ab*c";         // Wrong, it's a numeric type
178                                 enum one;                       // Wrong, it's a numeric type
179                                 bit two;                        // Wrong, it's a numeric type
180                         }
181                 }
182
183                 leaf leaf30 {
184                         type this:typedef3 {
185                                 enum three {            // Wrong, does not exit in original
186                                         value 13;
187                                 }
188                                 enum two {
189                                         value 99;               // Wrong, assigning different value
190                                 }
191                         }
192                 }
193
194                 leaf leaf31 {
195                         type this:typedef4 {
196                                 bit seven {                     // Wrong, does not exit in original
197                                         position 19;
198                                 }
199                                 bit six {
200                                         position 99;    // Wrong, assigning different position
201                                 }
202                         }
203                 }
204
205         }
206
207 // - - - - - - some legal and illegal length restrictions - - - - - -
208
209         typedef typedef51 {
210                 type string {
211                         length 10..20;
212                 }
213         }
214
215         typedef typedef52 {
216                 type string {
217                         length "10..20 | 50..60";
218                 }
219         }
220
221         container cont5 {
222
223                 leaf leaf51 {
224                         type this:typedef51 {
225                                 length 0..15;           // Illegal, Original restriction is [10-20]
226                         }
227                 }
228
229                 leaf leaf52 {
230                         type this:typedef51 {
231                                 length 9..20;           // Illegal, Original restriction is [10-20]
232                         }
233                 }
234
235                 leaf leaf53 {
236                         type this:typedef51 {
237                                 length 0..6;            // Illegal, Original restriction is [10-20]
238                         }
239                 }
240
241                 leaf leaf54 {
242                         type this:typedef51 {
243                                 length 10..100;         // Illegal, Original restriction is [10-20]
244                         }
245                 }
246
247                 leaf leaf55 {
248                         type this:typedef51 {
249                                 length "10..12 | 18..30";               // Illegal, Original restriction is [10-20]
250                         }
251                 }
252
253                 leaf leaf56 {
254                         type this:typedef52 {
255                                 length 0..15;           // Illegal, Original restriction is [10-20],[50-60]
256                         }
257                 }
258
259                 leaf leaf57 {
260                         type this:typedef52 {
261                                 length 55..65;          // Illegal, Original restriction is [10-20],[50-60]
262                         }
263                 }
264
265                 leaf leaf58 {
266                         type this:typedef52 {
267                                 length 15..55;          // Illegal, Original restriction is [10-20],[50-60]
268                         }
269                 }
270
271                 leaf leaf59 {
272                         type this:typedef52 {
273                                 length 5..55;           // Illegal, Original restriction is [10-20],[50-60]
274                         }
275                 }
276
277                 leaf leaf61 {
278                         type this:typedef51 {
279                                 length 10..20;          // OK, Original restriction is [10-20]
280                         }
281                 }
282
283                 leaf leaf62 {
284                         type this:typedef51 {
285                                 length "10..10 | 20..20";               // OK, Original restriction is [10-20]
286                         }
287                 }
288
289                 leaf leaf63 {
290                         type this:typedef51 {
291                                 length 10..15;          // OK, Original restriction is [10-20]
292                         }
293                 }
294
295                 leaf leaf64 {
296                         type this:typedef51 {
297                                 length 15..20;          // OK, Original restriction is [10-20]
298                         }
299                 }
300
301                 leaf leaf65 {
302                         type this:typedef51 {
303                                 length "10..12 | 13..20";               // OK, Original restriction is [10-20]
304                         }
305                 }
306
307                 leaf leaf66 {
308                         type this:typedef52 {
309                                 length 10..20;          // OK, Original restriction is [10-20],[50-60]
310                         }
311                 }
312
313                 leaf leaf67 {
314                         type this:typedef52 {
315                                 length 50..60;          // OK, Original restriction is [10-20],[50-60]
316                         }
317                 }
318
319                 leaf leaf68 {
320                         type this:typedef52 {
321                                 length 10..15;          // OK, Original restriction is [10-20],[50-60]
322                         }
323                 }
324
325                 leaf leaf69 {
326                         type this:typedef52 {
327                                 length 55..60;          // OK, Original restriction is [10-20],[50-60]
328                         }
329                 }
330
331                 leaf leaf70 {
332                         type this:typedef52 {
333                                 length "10..20 | 50..50";               // OK, Original restriction is [10-20],[50-60]
334                         }
335                 }
336
337                 leaf leaf71 {
338                         type this:typedef52 {
339                                 length "10..10";                // OK, Original restriction is [10-20],[50-60]
340                         }
341                 }
342
343                 leaf leaf72 {
344                         type this:typedef52 {
345                                 length "11..13 | 15..20";               // OK, Original restriction is [10-20],[50-60]
346                         }
347                 }
348
349                 leaf leaf73 {
350                         type this:typedef52 {
351                                 length "11..13 | 15..17 | 50..52";              // OK, Original restriction is [10-20],[50-60]
352                         }
353                 }
354         }
355
356
357 // - - - - - - some legal and illegal range restrictions - - - - - -
358
359         typedef typedef81 {
360                 type int32 {
361                         range -40..80;
362                 }
363         }
364
365         typedef typedef82 {
366                 type int32 {
367                         range "-90..-40 | -10..20 | 40..70";
368                 }
369         }
370
371         container cont8 {
372
373                 leaf leaf81 {
374                         type typedef81 {
375                                 range -50..-30;         // Illegal, original restriction is [-40..80]
376                         }
377                 }
378
379                 leaf leaf82 {
380                         type typedef81 {
381                                 range -40..90;          // Illegal, original restriction is [-40..80]
382                         }
383                 }
384
385                 leaf leaf83 {
386                         type typedef81 {
387                                 range -50..-45;         // Illegal, original restriction is [-40..80]
388                         }
389                 }
390
391                 leaf leaf84 {
392                         type typedef81 {
393                                 range 10..90;           // Illegal, original restriction is [-40..80]
394                         }
395                 }
396
397                 leaf leaf85 {
398                         type typedef81 {
399                                 range 80..90;           // Illegal, original restriction is [-40..80]
400                         }
401                 }
402
403                 leaf leaf86 {
404                         type typedef82 {
405                                 range -100..-80;                // Illegal, original restriction is [-90..-40] [-10..20] [40..70]
406                         }
407                 }
408
409                 leaf leaf87 {
410                         type typedef82 {
411                                 range -30..-20;         // Illegal, original restriction is [-90..-40] [-10..20] [40..70]
412                         }
413                 }
414
415                 leaf leaf88 {
416                         type typedef82 {
417                                 range 15..25;           // Illegal, original restriction is [-90..-40] [-10..20] [40..70]
418                         }
419                 }
420
421                 leaf leaf89 {
422                         type typedef82 {
423                                 range 30..40;           // Illegal, original restriction is [-90..-40] [-10..20] [40..70]
424                         }
425                 }
426
427                 leaf leaf91 {
428                         type typedef82 {
429                                 range -90..-40;         // OK, original restriction is [-90..-40] [-10..20] [40..70]
430                         }
431                 }
432
433                 leaf leaf92 {
434                         type typedef82 {
435                                 range "-90..-40 | -10..20";             // OK, original restriction is [-90..-40] [-10..20] [40..70]
436                         }
437                 }
438
439                 leaf leaf93 {
440                         type typedef82 {
441                                 range "0..10";          // OK, original restriction is [-90..-40] [-10..20] [40..70]
442                         }
443                 }
444
445                 leaf leaf94 {
446                         type typedef82 {
447                                 range "3..4 | 50..60";          // OK, original restriction is [-90..-40] [-10..20] [40..70]
448                         }
449                 }
450         }
451
452 }