Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

some webmachine_util tests

  • Loading branch information...
commit ef1d5bf81c22bed5e8108672664a45cb7cc55027 1 parent 449ee23
Bryan Fink beerriot authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 src/webmachine_util.erl
37 src/webmachine_util.erl
View
@@ -320,3 +320,40 @@ choose_media_type_qval_test() ->
|| I <- HtmlMatch ],
[ ?assertEqual("image/jpeg", choose_media_type(Provided, I))
|| I <- JpgMatch ].
+
+convert_request_date_test() ->
+ ?assertMatch({{_,_,_},{_,_,_}},
+ convert_request_date("Wed, 30 Dec 2009 14:39:02 GMT")),
+ ?assertMatch(bad_date,
+ convert_request_date(<<"does not handle binaries">>)).
+
+compare_ims_dates_test() ->
+ Late = {{2009,12,30},{14,39,02}},
+ Early = {{2009,12,30},{13,39,02}},
+ ?assertEqual(true, compare_ims_dates(Late, Early)),
+ ?assertEqual(false, compare_ims_dates(Early, Late)).
+
+guess_mime_test() ->
+ TextTypes = [".html",".css",".htc",".manifest",".txt"],
+ AppTypes = [".xhtml",".xml",".js",".swf",".zip",".bz2",
+ ".gz",".tar",".tgz"],
+ ImgTypes = [".jpg",".jpeg",".gif",".png",".ico",".svg"],
+ ?assertEqual([], [ T || T <- TextTypes,
+ 1 /= string:str(guess_mime(T),"text/") ]),
+ ?assertEqual([], [ T || T <- AppTypes,
+ 1 /= string:str(guess_mime(T),"application/") ]),
+ ?assertEqual([], [ T || T <- ImgTypes,
+ 1 /= string:str(guess_mime(T),"image/") ]).
+
+unquote_header_test() ->
+ ?assertEqual("hello", unquote_header("hello")),
+ ?assertEqual("hello", unquote_header("\"hello\"")),
+ ?assertEqual("hello", unquote_header("\"hello")),
+ ?assertEqual("hello", unquote_header("\"\\h\\e\\l\\l\\o\"")).
+
+now_diff_milliseconds_test() ->
+ Late = {10, 10, 10},
+ Early1 = {10, 9, 9},
+ Early2 = {9, 9, 9},
+ ?assertEqual(1000, now_diff_milliseconds(Late, Early1)),
+ ?assertEqual(1000001000, now_diff_milliseconds(Late, Early2)).
Please sign in to comment.
Something went wrong with that request. Please try again.