1
1
mirror of https://github.com/wader/fq.git synced 2024-12-02 12:45:53 +03:00
fq/pkg/interp/testdata/value_string.fqtest

132 lines
3.1 KiB
Plaintext
Raw Normal View History

2020-06-08 03:29:51 +03:00
/test.mp3:
# display
> fq -d mp3 '.headers[0].magic | ., type, length?' /test.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x0|49 44 33 |ID3 |.headers[0].magic: "ID3" (Correct)
"string"
3
# index
> fq -d mp3 '.headers[0].magic[0] | ., type, length?' /test.mp3
"I"
"string"
1
> fq -d mp3 '.headers[0].magic[-1000] | ., type, length?' /test.mp3
""
"string"
0
> fq -d mp3 '.headers[0].magic[1000] | ., type, length?' /test.mp3
""
"string"
0
# slice
> fq -d mp3 '.headers[0].magic[1:3] | ., type, length?' /test.mp3
"D3"
"string"
2
> fq -d mp3 '.headers[0].magic[0:-1] | ., type, length?' /test.mp3
"ID"
"string"
2
> fq -d mp3 '.headers[0].magic[-1000:2000] | ., type, length?' /test.mp3
"ID3"
"string"
3
# key
> fq -d mp3 '.headers[0].magic["test"] | ., type, length?' /test.mp3
exitcode: 5
stderr:
error: expected an object but got: string
# each
> fq -d mp3 '[.headers[0].magic[]] | type, length?' /test.mp3
exitcode: 5
stderr:
error: cannot iterate over: string
# keys
> fq -d mp3 '.headers[0].magic | keys' /test.mp3
exitcode: 5
stderr:
error: keys cannot be applied to: string
# has
> fq -d mp3 '.headers[0].magic | has("a")' /test.mp3
exitcode: 5
stderr:
error: has cannot be applied to: string
> fq -d mp3 '.headers[0].magic | has(0)' /test.mp3
exitcode: 5
stderr:
error: has cannot be applied to: string
# type
> fq -d mp3 '.headers[0].magic | type' /test.mp3
"string"
# tonumber
> fq -d mp3 '.headers[0].magic | tonumber' /test.mp3
exitcode: 5
stderr:
error: invalid number: "ID3"
# tostring
> fq -d mp3 '.headers[0].magic | tostring' /test.mp3
"ID3"
# to gojq
> fq -d mp3 '.headers[0].magic + ""' /test.mp3
"ID3"
> fq -d mp3 '.headers[0].magic + 1' /test.mp3
exitcode: 5
stderr:
error: cannot add: string ("ID3") and number (1)
# test _keys
> fq -d mp3 '.headers[0].magic._start | ., type, length?' /test.mp3
0
"number"
0
> fq -d mp3 '.headers[0].magic._stop | ., type, length?' /test.mp3
24
"number"
24
> fq -d mp3 '.headers[0].magic._len | ., type, length?' /test.mp3
24
"number"
24
> fq -d mp3 '.headers[0].magic._name | ., type, length?' /test.mp3
"magic"
"string"
5
> fq -d mp3 '.headers[0].magic._value | ., type, length?' /test.mp3
"ID3"
"string"
3
> fq -d mp3 '.headers[0].magic._symbol | ., type, length?' /test.mp3
""
"string"
0
> fq -d mp3 '.headers[0].magic._description | ., type, length?' /test.mp3
"Correct"
"string"
7
> fq -d mp3 '.headers[0].magic._path | ., type, length?' /test.mp3
[
"headers",
0,
"magic"
]
"array"
3
> fq -d mp3 '.headers[0].magic._bits | ., type, length?' /test.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x0|49 44 33 |ID3 |
<24 bits>
"buffer"
24
> fq -d mp3 '.headers[0].magic._bytes | ., type, length?' /test.mp3
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f| |
0x0|49 44 33 |ID3 |
<3 bytes>
"buffer"
3
> fq -d mp3 '.headers[0].magic._error | ., type, length?' /test.mp3
null
"null"
0
> fq -d mp3 '.headers[0].magic._unknown | ., type, length?' /test.mp3
false
"boolean"