1
1
mirror of https://github.com/wader/fq.git synced 2024-12-27 15:42:07 +03:00
fq/pkg/interp/testdata/value_null.fqtest
Mattias Wadman 051a70bd4b interp: Change bit ranges to use exclusive end
All other ranges and slicing uses exclusive end so i think it make sense
to make it consistent.

Update docs and add additional example for non-byte-aligned field.

Also fixes issue showing zero bit ranges as start-NA.
2023-10-20 15:37:26 +02:00

128 lines
4.7 KiB
Plaintext

$ fq -i -d mp3 . test.mp3
mp3> .headers[0].padding | ., tovalue, toactual, tosym, type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x20| 00 00 00 00 00 00 00 00 00 00 | .......... |.headers[0].padding: raw bits (all zero)
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
null
"string"
10
mp3> .headers[0].padding[0] | ., type, length?
"\u0000"
"string"
1
mp3> .headers[0].padding[-1000] | ., type, length?
""
"string"
0
mp3> .headers[0].padding[1000] | ., type, length?
""
"string"
0
mp3> .headers[0].padding[1:3] | ., type, length?
"\u0000\u0000"
"string"
2
mp3> .headers[0].padding[0:-1] | ., type, length?
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
"string"
9
mp3> .headers[0].padding[-1000:2000] | ., type, length?
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
"string"
10
mp3> .headers[0].padding["test"] | ., type, length?
null
"null"
0
mp3> [.headers[0].padding[]] | type, length?
error: cannot iterate over: string
mp3> .headers[0].padding | keys
error: keys cannot be applied to: string
mp3> .headers[0].padding | has("a")
error: has cannot be applied to: string
mp3> .headers[0].padding | has(0)
error: has cannot be applied to: string
mp3> .headers[0].padding | type
"string"
mp3> .headers[0].padding | tonumber
error: invalid number: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
mp3> .headers[0].padding | tostring
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
mp3> .headers[0].padding + ""
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
mp3> .headers[0].padding + 1
error: cannot add: string ("\u0000\u0000\u0000\u0000 ...") and number (1)
mp3> .headers[0].padding._start | ., type, length?
280
"number"
280
mp3> .headers[0].padding._stop | ., type, length?
360
"number"
360
mp3> .headers[0].padding._len | ., type, length?
80
"number"
80
mp3> .headers[0].padding._name | ., type, length?
"padding"
"string"
7
mp3> .headers[0].padding._actual | ., type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x20| 00 00 00 00 00 00 00 00 00 00 | .......... |.headers[0].padding: raw bits (all zero)
"string"
10
mp3> .headers[0].padding._sym | ., type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x20| 00 00 00 00 00 00 00 00 00 00 | .......... |.headers[0].padding: raw bits (all zero)
"null"
0
mp3> .headers[0].padding._description | ., type, length?
"all zero"
"string"
8
mp3> .headers[0].padding._path | ., type, length?
[
"headers",
0,
"padding"
]
"array"
3
mp3> .headers[0].padding._bits | ., type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x20| 00 00 00 00 00 00 00 00 00 00 | .......... |.: raw bits 0x23-0x2d (10)
"string"
80
mp3> .headers[0].padding._bytes | ., type, length?
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x20| 00 00 00 00 00 00 00 00 00 00 | .......... |.: raw bits 0x23-0x2d (10)
"string"
10
mp3> .headers[0].padding._error | ., type, length?
null
"null"
0
mp3> .headers[0].padding._gap | ., type, length?
false
"boolean"
mp3> .headers[0].padding.a = 1
error: setpath(["headers",0,"padding","a"]; 1) cannot be applied to {"footers":[],"frames":[{" ...: expected an object but got: string ("\u0000\u0000\u0000\u0000 ...")
mp3> .headers[0].padding[0] = 1
error: setpath(["headers",0,"padding",0]; 1) cannot be applied to {"footers":[],"frames":[{" ...: expected an array but got: string ("\u0000\u0000\u0000\u0000 ...")
mp3> .headers[0].padding.a |= empty
error: delpaths([["headers",0,"padding","a"]]) cannot be applied to {"footers":[],"frames":[{" ...: expected an object but got: string ("\u0000\u0000\u0000\u0000 ...")
mp3> .headers[0].padding[0] |= empty
error: delpaths([["headers",0,"padding",0]]) cannot be applied to {"footers":[],"frames":[{" ...: expected an array but got: string ("\u0000\u0000\u0000\u0000 ...")
mp3> .headers[0].padding | setpath(["a"]; 1)
error: setpath(["a"]; 1) cannot be applied to "\u0000\u0000\u0000\u0000\ ...: expected an object but got: string ("\u0000\u0000\u0000\u0000 ...")
mp3> .headers[0].padding | setpath([0]; 1)
error: setpath([0]; 1) cannot be applied to "\u0000\u0000\u0000\u0000\ ...: expected an array but got: string ("\u0000\u0000\u0000\u0000 ...")
mp3> .headers[0].padding | delpaths([["a"]])
error: delpaths([["a"]]) cannot be applied to "\u0000\u0000\u0000\u0000\ ...: expected an object but got: string ("\u0000\u0000\u0000\u0000 ...")
mp3> .headers[0].padding | delpaths([[0]])
error: delpaths([[0]]) cannot be applied to "\u0000\u0000\u0000\u0000\ ...: expected an array but got: string ("\u0000\u0000\u0000\u0000 ...")
mp3> ^D