Skip to content

Commit 98a68fc

Browse files
committed
Add ValidFailRepeat{Contents,Expr,Inst,{Anyof,Eq,Max,Min}Int}
See kaitai-io/kaitai_struct#1117
1 parent 9fd16de commit 98a68fc

15 files changed

+86
-1
lines changed

formats/valid_fail_expr.ksy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ seq:
77
expr: _ == 1
88
- id: bar
99
type: s2le
10-
valid: # there's actually -190 in the file
10+
valid: # there is actually -190 in the file
1111
expr: _ < -190 or _ > -190
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
meta:
2+
id: valid_fail_repeat_anyof_int
3+
seq:
4+
- id: foo
5+
type: u1
6+
valid: # there is actually 0xe8 in the file
7+
any-of:
8+
- 0
9+
- 1
10+
- 0x41
11+
repeat: eos
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
meta:
2+
id: valid_fail_repeat_contents
3+
seq:
4+
- id: foo
5+
contents: [0x12, 0x34, 0x56, 0x78] # there is actually [0x00, 0x12, 0x34, 0x56] in the file
6+
repeat: eos

formats/valid_fail_repeat_eq_int.ksy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
meta:
2+
id: valid_fail_repeat_eq_int
3+
endian: be
4+
seq:
5+
- id: foo
6+
type: u4
7+
valid: 0x12_34_56_78 # there is actually 0x00_12_34_56 in the file
8+
repeat: eos

formats/valid_fail_repeat_expr.ksy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
meta:
2+
id: valid_fail_repeat_expr
3+
seq:
4+
- id: foo
5+
size: 4
6+
valid:
7+
# there is actually [0x00, 0x12, 0x34, 0x56] in the file
8+
# (this `valid/expr` asserts that this particular value does not occur)
9+
expr: _ != [0x00, 0x12, 0x34, 0x56]
10+
repeat: eos

formats/valid_fail_repeat_inst.ksy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
meta:
2+
id: valid_fail_repeat_inst
3+
endian: be
4+
seq:
5+
- id: a
6+
size: 0
7+
if: inst.size == 0 # invoke instance
8+
instances:
9+
inst:
10+
pos: 0
11+
type: u4
12+
valid: 0x12_34_56_78 # there is actually 0x00_12_34_56 in the file
13+
repeat: eos

formats/valid_fail_repeat_max_int.ksy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
meta:
2+
id: valid_fail_repeat_max_int
3+
seq:
4+
- id: foo
5+
type: u1
6+
valid:
7+
max: 0xfe # there is actually 0xff in the file
8+
repeat: eos

formats/valid_fail_repeat_min_int.ksy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
meta:
2+
id: valid_fail_repeat_min_int
3+
seq:
4+
- id: foo
5+
type: s1
6+
valid:
7+
min: 0 # there is actually -24 (0xe8) in the file
8+
repeat: eos
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id: valid_fail_repeat_anyof_int
2+
data: process_coerce_bytes.bin
3+
exception: ValidationNotAnyOfError<u1>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id: valid_fail_repeat_contents
2+
data: bcd_user_type_be.bin
3+
exception: ValidationNotEqualError<bytes>

0 commit comments

Comments
 (0)