Browse Source

Make the latin1 cyrillic route tests work on R17+

Instead of relying on the encoding of the file we now simply
have list of numbers as they would be inside a latin1 file.
Loïc Hoguin 11 years ago
parent
commit
abf246c9aa
1 changed files with 19 additions and 8 deletions
  1. 19 8
      src/cowboy_router.erl

+ 19 - 8
src/cowboy_router.erl

@@ -390,14 +390,22 @@ compile_test_() ->
 				{[<<"path">>, <<"to">>, <<"resource">>], [], hb, ob}]}]},
 				{[<<"path">>, <<"to">>, <<"resource">>], [], hb, ob}]}]},
 		{[{'_', [{"/path/to/resource/", h, o}]}],
 		{[{'_', [{"/path/to/resource/", h, o}]}],
 			[{'_', [], [{[<<"path">>, <<"to">>, <<"resource">>], [], h, o}]}]},
 			[{'_', [], [{[<<"path">>, <<"to">>, <<"resource">>], [], h, o}]}]},
-		{[{'_', [{"/путь/к/ресурсу/", h, o}]}],
-			[{'_', [], [{[<<"путь">>, <<"к">>, <<"ресурсу">>], [], h, o}]}]},
+		% Cyrillic from a latin1 encoded file.
+		{[{'_', [{[47,208,191,209,131,209,130,209,140,47,208,186,47,209,128,
+				208,181,209,129,209,131,209,128,209,129,209,131,47], h, o}]}],
+			[{'_', [], [{[<<208,191,209,131,209,130,209,140>>, <<208,186>>,
+				<<209,128,208,181,209,129,209,131,209,128,209,129,209,131>>],
+				[], h, o}]}]},
 		{[{"cowboy.example.org.", [{'_', h, o}]}],
 		{[{"cowboy.example.org.", [{'_', h, o}]}],
 			[{[<<"org">>, <<"example">>, <<"cowboy">>], [], [{'_', [], h, o}]}]},
 			[{[<<"org">>, <<"example">>, <<"cowboy">>], [], [{'_', [], h, o}]}]},
 		{[{".cowboy.example.org", [{'_', h, o}]}],
 		{[{".cowboy.example.org", [{'_', h, o}]}],
 			[{[<<"org">>, <<"example">>, <<"cowboy">>], [], [{'_', [], h, o}]}]},
 			[{[<<"org">>, <<"example">>, <<"cowboy">>], [], [{'_', [], h, o}]}]},
-		{[{"некий.сайт.рф.", [{'_', h, o}]}],
-			[{[<<"рф">>, <<"сайт">>, <<"некий">>], [], [{'_', [], h, o}]}]},
+		% Cyrillic from a latin1 encoded file.
+		{[{[208,189,208,181,208,186,208,184,208,185,46,209,129,208,176,
+				208,185,209,130,46,209,128,209,132,46], [{'_', h, o}]}],
+			[{[<<209,128,209,132>>, <<209,129,208,176,208,185,209,130>>,
+				<<208,189,208,181,208,186,208,184,208,185>>],
+				[], [{'_', [], h, o}]}]},
 		{[{":subdomain.example.org", [{"/hats/:name/prices", h, o}]}],
 		{[{":subdomain.example.org", [{"/hats/:name/prices", h, o}]}],
 			[{[<<"org">>, <<"example">>, subdomain], [], [
 			[{[<<"org">>, <<"example">>, subdomain], [], [
 				{[<<"hats">>, name, <<"prices">>], [], h, o}]}]},
 				{[<<"hats">>, name, <<"prices">>], [], h, o}]}]},
@@ -506,8 +514,9 @@ match_info_test_() ->
 		{[<<"eu">>, <<"ninenines">>, '...'], [], [
 		{[<<"eu">>, <<"ninenines">>, '...'], [], [
 			{'_', [], match_any, []}
 			{'_', [], match_any, []}
 		]},
 		]},
-		{[<<"рф">>, <<"сайт">>], [], [
-			{[<<"путь">>, '...'], [], match_path, []}
+		% Cyrillic from a latin1 encoded file.
+		{[<<209,128,209,132>>, <<209,129,208,176,208,185,209,130>>], [], [
+			{[<<208,191,209,131,209,130,209,140>>, '...'], [], match_path, []}
 		]}
 		]}
 	],
 	],
 	Tests = [
 	Tests = [
@@ -523,8 +532,10 @@ match_info_test_() ->
 			{ok, match_path, [], [], undefined, [<<"path_info">>]}},
 			{ok, match_path, [], [], undefined, [<<"path_info">>]}},
 		{<<"www.ninenines.eu">>, <<"/pathinfo/is/next/foo/bar">>,
 		{<<"www.ninenines.eu">>, <<"/pathinfo/is/next/foo/bar">>,
 			{ok, match_path, [], [], undefined, [<<"foo">>, <<"bar">>]}},
 			{ok, match_path, [], [], undefined, [<<"foo">>, <<"bar">>]}},
-		{<<"сайт.рф">>, <<"/путь/домой">>,
-			{ok, match_path, [], [], undefined, [<<"домой">>]}}
+		% Cyrillic from a latin1 encoded file.
+		{<<209,129,208,176,208,185,209,130,46,209,128,209,132>>,
+			<<47,208,191,209,131,209,130,209,140,47,208,180,208,190,208,188,208,190,208,185>>,
+			{ok, match_path, [], [], undefined, [<<208,180,208,190,208,188,208,190,208,185>>]}}
 	],
 	],
 	[{lists:flatten(io_lib:format("~p, ~p", [H, P])), fun() ->
 	[{lists:flatten(io_lib:format("~p, ~p", [H, P])), fun() ->
 		R = match(Dispatch, H, P)
 		R = match(Dispatch, H, P)