basho / webmachine (http://webmachine.basho.com/)
A REST-based system for building web applications.
| commit 113: | 0b8aac8fa334 |
| parent 112: | 9957a15e5779 |
| branch: | default |
some webmachine_util tests
7 months ago
Changed (Δ1.5 KB):
raw changeset »
src/webmachine_util.erl (37 lines added, 0 lines removed)
Up to file-list src/webmachine_util.erl:
| … | … | @@ -320,3 +320,40 @@ choose_media_type_qval_test() -> |
320 |
320 |
|| I <- HtmlMatch ], |
321 |
321 |
[ ?assertEqual("image/jpeg", choose_media_type(Provided, I)) |
322 |
322 |
|| I <- JpgMatch ]. |
323 |
||
324 |
convert_request_date_test() -> |
|
325 |
?assertMatch({{_,_,_},{_,_,_}}, |
|
326 |
convert_request_date("Wed, 30 Dec 2009 14:39:02 GMT")), |
|
327 |
?assertMatch(bad_date, |
|
328 |
convert_request_date(<<"does not handle binaries">>)). |
|
329 |
||
330 |
compare_ims_dates_test() -> |
|
331 |
Late = {{2009,12,30},{14,39,02}}, |
|
332 |
Early = {{2009,12,30},{13,39,02}}, |
|
333 |
?assertEqual(true, compare_ims_dates(Late, Early)), |
|
334 |
?assertEqual(false, compare_ims_dates(Early, Late)). |
|
335 |
||
336 |
guess_mime_test() -> |
|
337 |
TextTypes = [".html",".css",".htc",".manifest",".txt"], |
|
338 |
AppTypes = [".xhtml",".xml",".js",".swf",".zip",".bz2", |
|
339 |
".gz",".tar",".tgz"], |
|
340 |
ImgTypes = [".jpg",".jpeg",".gif",".png",".ico",".svg"], |
|
341 |
?assertEqual([], [ T || T <- TextTypes, |
|
342 |
1 /= string:str(guess_mime(T),"text/") ]), |
|
343 |
?assertEqual([], [ T || T <- AppTypes, |
|
344 |
1 /= string:str(guess_mime(T),"application/") ]), |
|
345 |
?assertEqual([], [ T || T <- ImgTypes, |
|
346 |
1 /= string:str(guess_mime(T),"image/") ]). |
|
347 |
||
348 |
unquote_header_test() -> |
|
349 |
?assertEqual("hello", unquote_header("hello")), |
|
350 |
?assertEqual("hello", unquote_header("\"hello\"")), |
|
351 |
?assertEqual("hello", unquote_header("\"hello")), |
|
352 |
?assertEqual("hello", unquote_header("\"\\h\\e\\l\\l\\o\"")). |
|
353 |
||
354 |
now_diff_milliseconds_test() -> |
|
355 |
Late = {10, 10, 10}, |
|
356 |
Early1 = {10, 9, 9}, |
|
357 |
Early2 = {9, 9, 9}, |
|
358 |
?assertEqual(1000, now_diff_milliseconds(Late, Early1)), |
|
359 |
?assertEqual(1000001000, now_diff_milliseconds(Late, Early2)). |
