diff options
author | Péter Dimitrov <[email protected]> | 2017-10-11 16:36:14 +0200 |
---|---|---|
committer | Péter Dimitrov <[email protected]> | 2017-10-23 15:53:29 +0200 |
commit | 4a2358bbf4a4049a765aab435a31daeeffbbd677 (patch) | |
tree | 952cd88b02a192fa6a2dc8d4d0476d222fe5f13c /lib/stdlib/test/uri_string_SUITE.erl | |
parent | 1335e59a60d5e195baf519d2c52b0ca0aa96831f (diff) | |
download | otp-4a2358bbf4a4049a765aab435a31daeeffbbd677.tar.gz otp-4a2358bbf4a4049a765aab435a31daeeffbbd677.tar.bz2 otp-4a2358bbf4a4049a765aab435a31daeeffbbd677.zip |
stdlib: Implement transcode/2.
Diffstat (limited to 'lib/stdlib/test/uri_string_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/uri_string_SUITE.erl | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/lib/stdlib/test/uri_string_SUITE.erl b/lib/stdlib/test/uri_string_SUITE.erl index cd2e003d02..83f702dd13 100644 --- a/lib/stdlib/test/uri_string_SUITE.erl +++ b/lib/stdlib/test/uri_string_SUITE.erl @@ -36,7 +36,8 @@ recompose_fragment/1, recompose_parse_fragment/1, recompose_query/1, recompose_parse_query/1, recompose_path/1, recompose_parse_path/1, - recompose_autogen/1, parse_recompose_autogen/1 + recompose_autogen/1, parse_recompose_autogen/1, + transcode_basic/1, transcode_options/1, transcode_mixed/1, transcode_negative/1 ]). @@ -99,7 +100,11 @@ all() -> recompose_path, recompose_parse_path, recompose_autogen, - parse_recompose_autogen + parse_recompose_autogen, + transcode_basic, + transcode_options, + transcode_mixed, + transcode_negative ]. groups() -> @@ -763,3 +768,33 @@ recompose_autogen(_Config) -> parse_recompose_autogen(_Config) -> Tests = generate_test_vectors(uri_combinations()), lists:map(fun run_test_parse_recompose/1, Tests). + +transcode_basic(_Config) -> + <<"foo%C3%B6bar"/utf8>> = + uri_string:transcode(<<"foo%00%00%00%F6bar"/utf32>>, [{in_encoding, utf32},{out_encoding, utf8}]), + "foo%C3%B6bar" = + uri_string:transcode("foo%00%00%00%F6bar", [{in_encoding, utf32},{out_encoding, utf8}]), + <<"foo%00%00%00%F6bar"/utf32>> = + uri_string:transcode(<<"foo%C3%B6bar"/utf8>>, [{in_encoding, utf8},{out_encoding, utf32}]), + "foo%00%00%00%F6bar" = + uri_string:transcode("foo%C3%B6bar", [{in_encoding, utf8},{out_encoding, utf32}]), + "foo%C3%B6bar" = + uri_string:transcode("foo%F6bar", [{in_encoding, latin1},{out_encoding, utf8}]). + +transcode_options(_Config) -> + <<"foo%C3%B6bar"/utf8>> = + uri_string:transcode(<<"foo%C3%B6bar"/utf8>>, []), + <<"foo%C3%B6bar"/utf8>> = + uri_string:transcode(<<"foo%00%00%00%F6bar"/utf32>>, [{in_encoding, utf32}]), + <<"foo%00%00%00%F6bar"/utf32>> = + uri_string:transcode(<<"foo%C3%B6bar"/utf8>>, [{out_encoding, utf32}]). + +transcode_mixed(_Config) -> + "foo%00%00%00%F6bar" = + uri_string:transcode(["foo",<<"%C3%B6"/utf8>>,<<"ba"/utf8>>,"r"], [{out_encoding, utf32}]). + +transcode_negative(_Config) -> + {invalid_input,"foo","BX"} = + uri_string:transcode(<<"foo%C3%BXbar"/utf8>>, [{in_encoding, utf8},{out_encoding, utf32}]), + {invalid_input,<<>>,<<"ö">>} = + uri_string:transcode("foo%F6bar", [{in_encoding, utf8},{out_encoding, utf8}]). |