aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2017-10-27 14:14:22 +0200
committerPéter Dimitrov <[email protected]>2017-10-27 14:59:06 +0200
commit3d12c8f164f79dd67967ba5c7df7d3c555dc0f29 (patch)
treea4ffbba31c99aab990f752c92df9f8b4858ab39d /lib/stdlib/test
parentb0c682a8118c5775da784e9a0f569ee995319f80 (diff)
downloadotp-3d12c8f164f79dd67967ba5c7df7d3c555dc0f29.tar.gz
otp-3d12c8f164f79dd67967ba5c7df7d3c555dc0f29.tar.bz2
otp-3d12c8f164f79dd67967ba5c7df7d3c555dc0f29.zip
stdlib: Allow undefined port in uri_map()
uri_map() updated to allow 'undefined' ports in order to align the implementation with RFC 3986: port = *DIGIT An 'undefined' port is mapped to a ":" during recompose operation.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/property_test/uri_string_recompose.erl5
-rw-r--r--lib/stdlib/test/uri_string_SUITE.erl11
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/stdlib/test/property_test/uri_string_recompose.erl b/lib/stdlib/test/property_test/uri_string_recompose.erl
index 97f9d727a0..e51a671172 100644
--- a/lib/stdlib/test/property_test/uri_string_recompose.erl
+++ b/lib/stdlib/test/property_test/uri_string_recompose.erl
@@ -267,8 +267,9 @@ host_uri() ->
%% Port, Query, Fragment
%%-------------------------------------------------------------------------
port() ->
- range(1,65535).
-
+ frequency([{10, undefined},
+ {10, range(1,65535)}
+ ]).
query_map() ->
unicode().
diff --git a/lib/stdlib/test/uri_string_SUITE.erl b/lib/stdlib/test/uri_string_SUITE.erl
index 95a49f5eb3..9ee321c509 100644
--- a/lib/stdlib/test/uri_string_SUITE.erl
+++ b/lib/stdlib/test/uri_string_SUITE.erl
@@ -692,7 +692,9 @@ parse_special2(_Config) ->
#{host := [],path := [],userinfo := []} = uri_string:parse("//@"),
#{host := [],path := [],scheme := "foo",userinfo := []} = uri_string:parse("foo://@"),
#{host := [],path := "/",userinfo := []} = uri_string:parse("//@/"),
- #{host := [],path := "/",scheme := "foo",userinfo := []} = uri_string:parse("foo://@/").
+ #{host := [],path := "/",scheme := "foo",userinfo := []} = uri_string:parse("foo://@/"),
+ #{host := "localhost",path := "/",port := undefined} = uri_string:parse("//localhost:/"),
+ #{host := [],path := [],port := undefined} = uri_string:parse("//:").
parse_negative(_Config) ->
{error,invalid_uri,"å"} = uri_string:parse("å"),
@@ -702,7 +704,8 @@ parse_negative(_Config) ->
{error,invalid_uri,"ö"} = uri_string:parse("//host/path#foö"),
{error,invalid_uri,"127.256.0.1"} = uri_string:parse("//127.256.0.1"),
{error,invalid_uri,":::127.0.0.1"} = uri_string:parse("//[:::127.0.0.1]"),
- {error,non_utf8,<<0,0,0,246>>} = uri_string:parse("//%00%00%00%F6").
+ {error,invalid_utf8,<<0,0,0,246>>} = uri_string:parse("//%00%00%00%F6"),
+ {error,invalid_uri,"A"} = uri_string:parse("//localhost:A8").
%%-------------------------------------------------------------------------
@@ -836,8 +839,8 @@ compose_query(_Config) ->
uri_string:compose_query([{<<"foo bar">>,<<"1">>}, {<<"ö"/utf8>>, <<"2">>}]).
compose_query_negative(_Config) ->
- {error,badarg,4} = uri_string:compose_query([{"",4}]),
- {error,badarg,5} = uri_string:compose_query([{5,""}]),
+ {error,invalid_input,4} = uri_string:compose_query([{"",4}]),
+ {error,invalid_input,5} = uri_string:compose_query([{5,""}]),
{error,invalid_utf8,<<"ö">>} = uri_string:compose_query([{"foo bar","1"}, {<<"ö">>, "2"}]).
dissect_query(_Config) ->