This commit improves performance by refactoring `@uri` and `@urid` to pre-alloacte buffers and build the `jv` string at the end. Also, this fixes `@urid` to prevent multi-byte UTF-8 corruption, and to preserve embedded null bytes.
93 lines
1.6 KiB
Plaintext
93 lines
1.6 KiB
Plaintext
# Tests are groups of three lines: program, input, expected output
|
|
# Blank lines and lines starting with # are ignored
|
|
|
|
# @uri
|
|
|
|
@uri
|
|
""
|
|
""
|
|
|
|
@uri
|
|
"\b\t\n\f\r\"\\"
|
|
"%08%09%0A%0C%0D%22%5C"
|
|
|
|
@uri
|
|
",-./09:;<=>?@AZ[\\]^_`az{|}~\u007f"
|
|
"%2C-.%2F09%3A%3B%3C%3D%3E%3F%40AZ%5B%5C%5D%5E_%60az%7B%7C%7D~%7F"
|
|
|
|
@uri
|
|
"a \u03bc \u2230 \ud83d\ude0e"
|
|
"a%20%CE%BC%20%E2%88%B0%20%F0%9F%98%8E"
|
|
|
|
@uri
|
|
"a\u0000b\u0000c"
|
|
"a%00b%00c"
|
|
|
|
# @urid
|
|
|
|
@urid
|
|
""
|
|
""
|
|
|
|
@urid
|
|
"%08%09%0A%0C%0D%22%5C"
|
|
"\b\t\n\f\r\"\\"
|
|
|
|
@urid
|
|
"%2C-.%2F09%3A%3B%3C%3D%3E%3F%40AZ%5B%5C%5D%5E_%60az%7B%7C%7D~%7F"
|
|
",-./09:;<=>?@AZ[\\]^_`az{|}~\u007f"
|
|
|
|
@urid
|
|
"a%20%CE%BC%20%E2%88%B0%20%F0%9F%98%8E"
|
|
"a \u03bc \u2230 \ud83d\ude0e"
|
|
|
|
@urid
|
|
"a%00b%00c"
|
|
"a\u0000b\u0000c"
|
|
|
|
@urid
|
|
"hello world"
|
|
"hello world"
|
|
|
|
@urid
|
|
"Knäckebröd"
|
|
"Knäckebröd"
|
|
|
|
@urid
|
|
"%c3%a4b%c3%a7d%c3%ab"
|
|
"äbçdë"
|
|
|
|
@urid
|
|
"a\u0000b\u0000c"
|
|
"a\u0000b\u0000c"
|
|
|
|
# '%' at end of string
|
|
. | try @urid catch .
|
|
"abc%"
|
|
"string (\"abc%\") is not a valid uri encoding"
|
|
|
|
# '%' followed by only one hex digit
|
|
. | try @urid catch .
|
|
"abc%f"
|
|
"string (\"abc%f\") is not a valid uri encoding"
|
|
|
|
# '%' followed by non-hex character
|
|
. | try @urid catch .
|
|
"abc%g"
|
|
"string (\"abc%g\") is not a valid uri encoding"
|
|
|
|
# invalid hex value ('FX')
|
|
. | try @urid catch .
|
|
"%FX%9F%98%8E"
|
|
"string (\"%FX%9F%98%8E\") is not a valid uri encoding"
|
|
|
|
# incomplete 4-byte UTF-8 sequence (only 3 bytes)
|
|
. | try @urid catch .
|
|
"%F0%93%81"
|
|
"string (\"%F0%93%81\") is not a valid uri encoding"
|
|
|
|
# invalid continuation byte (0xC0 is not 10xxxxxx)
|
|
. | try @urid catch .
|
|
"%F0%C0%81%8E"
|
|
"string (\"%F0%C0%81%8E\") is not a valid uri encoding"
|