b8793f7470496b97a39ed9481650be097c0b8c74
[smo/teiv.git] /
1 module general-syntax-test-constraints {
2
3     namespace "test:general-syntax-test-constraints";
4     prefix this;
5
6         description
7         "Copyright (C) 2024 Ericsson
8         Modifications Copyright (C) 2024 OpenInfra Foundation Europe";
9
10     revision "2020-07-22" {
11         description "Initial revision";
12     }
13
14     // - - - - length - - - -
15
16     container cont1 {
17
18         leaf leaf1 {
19                 type string {
20                         length 1..10 {
21                                 error-app-tag "some-app-tag";
22                                 error-message "wrong length";
23                         }
24                 }
25         }
26
27                 leaf leaf2 {
28                 type string {
29                         length min..max;
30                 }
31         }
32
33                 leaf leaf3 {
34                 type string {
35                         length "min..10 | 15 | 20..max";
36                 }
37         }
38
39                 leaf leaf4 {
40                 type string {
41                         length "min .. min | max ..max";                // doesn't really make sense, but technically allowed
42                 }
43         }
44
45                 leaf leaf5 {
46                 type string {
47                         length min..max|;               // Wrong
48                 }
49         }
50
51                 leaf leaf6 {
52                 type string {
53                         length |min..max;               // Wrong
54                 }
55         }
56
57         leaf leaf7 {
58                 type string {
59                         length zero..1.1;               // Wrong
60                 }
61         }
62
63         leaf leaf8 {
64                 type string {
65                         length "10..20 | 21..30";               // OK
66                 }
67         }
68
69         leaf leaf9 {
70                 type string {
71                         length "10..20 | 20..30";               // Wrong, overlap
72                 }
73         }
74
75         leaf leaf10 {
76                 type string {
77                         length "19..30 | 10..20";               // Wrong order
78                 }
79         }
80
81                 leaf leaf11 {
82                 type string {
83                         length "-1..-3";                // Wrong, negative.
84                 }
85         }
86
87         leaf leaf12 {
88                 type string {
89                         length "..10..20 | 21..30";             // Wrong
90                 }
91         }
92
93         leaf leaf13 {
94                 type string {
95                         length "10..20 | 21..30..";             // Wrong
96                 }
97         }
98     }
99
100         // -------------- Range for integer -------------------
101
102     container cont2 {
103
104         leaf leaf1 {
105                 type int32 {
106                         range 1..10 {
107                                 error-app-tag "some-app-tag";
108                                 error-message "wrong length";
109                         }
110                 }
111         }
112
113                 leaf leaf2 {
114                 type uint8 {
115                         range min..max;
116                 }
117         }
118
119                 leaf leaf3 {
120                 type uint16 {
121                         range min..max;
122                 }
123         }
124
125                 leaf leaf4 {
126                 type uint32 {
127                         range min..max;
128                 }
129         }
130
131                 leaf leaf5 {
132                 type uint64 {
133                         range min..max;
134                 }
135         }
136
137                 leaf leaf6 {
138                 type int8 {
139                         range min..max;
140                 }
141         }
142
143                 leaf leaf7 {
144                 type int16 {
145                         range min..max;
146                 }
147         }
148
149                 leaf leaf8 {
150                 type int32 {
151                         range min..max;
152                 }
153         }
154
155                 leaf leaf9 {
156                 type int64 {
157                         range min..max;
158                 }
159         }
160
161         leaf leaf10 {
162                 type int32 {
163                         range 10.0..20.0;
164                 }
165         }
166
167         leaf leaf11 {
168                 type int32 {
169                         range "10..20 | 30 .. 40";
170                 }
171         }
172
173         leaf leaf12 {
174                 type int32 {
175                         range "10..20 | 25 | 30 .. 40";
176                 }
177         }
178
179         leaf leaf13 {
180                 type uint8 {
181                         range "min..min | max .. max";
182                 }
183         }
184
185         leaf leaf14 {
186                 type uint8 {
187                         range " | 10";
188                 }
189         }
190
191         leaf leaf15 {
192                 type uint8 {
193                         range "10 | ";
194                 }
195         }
196
197         leaf leaf16 {
198                 type uint8 {
199                         range "zero .. 10";
200                 }
201         }
202
203                 leaf leaf17 {
204                 type uint8 {
205                         range "10 .. 20 | .. 30";
206                 }
207         }
208
209                 leaf leaf18 {
210                 type uint8 {
211                         range "10 .. | 20 .. 30";
212                 }
213         }
214
215                 leaf leaf19 {
216                 type uint8 {
217                         range "10 .. 20 | 20 .. 30";
218                 }
219         }
220
221                 leaf leaf20 {
222                 type uint8 {
223                         range "20 .. 10 | 25 .. 30";
224                 }
225         }
226
227                 leaf leaf21 {
228                 type uint8 {
229                         range "30 .. 40 | 10 .. 20";
230                 }
231         }
232
233                 leaf leaf22 {
234                 type uint8 {
235                         range "-100 .. -90 | -80 .. -70";
236                 }
237         }
238
239                 leaf leaf23 {
240                 type uint8 {
241                         range "400 .. 410 | 610 .. 620";
242                 }
243         }
244
245                 leaf leaf24 {
246                 type uint8 {
247                         range "10.5 .. 20.8";
248                 }
249         }
250
251                 leaf leaf25 {
252                 type boolean {
253                         range "10 .. 20";
254                 }
255         }
256     }
257
258         // -------------- Range for decimal64 -------------------
259
260     container cont3 {
261
262                 leaf leaf1 {
263                 type decimal64 {
264                         fraction-digits 1;
265                         range min..max;
266                 }
267         }
268
269                 leaf leaf2 {
270                 type decimal64 {
271                         fraction-digits 18;
272                         range min..max;
273                 }
274         }
275
276                 leaf leaf3 {
277                 type decimal64 {                // missing fraction digits statement, should issue finding
278                         range min..max;
279                 }
280         }
281         }
282
283 }