-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathtest_method.ml
41 lines (37 loc) · 2.01 KB
/
test_method.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
open Httpaf
open Method
let test_is_safe () =
Alcotest.(check bool) "GET is safe" (is_safe `GET ) true;
Alcotest.(check bool) "HEAD is safe" (is_safe `HEAD) true;
Alcotest.(check bool) "POST is safe" (is_safe `POST) false;
Alcotest.(check bool) "PUT is safe" (is_safe `PUT ) false;
Alcotest.(check bool) "DELETE is safe" (is_safe `DELETE ) false;
Alcotest.(check bool) "CONNECT is safe" (is_safe `CONNECT) false;
Alcotest.(check bool) "OPTIONS is safe" (is_safe `OPTIONS) true;
Alcotest.(check bool) "TRACE is safe" (is_safe `TRACE ) true;
;;
let test_is_cacheable () =
Alcotest.(check bool) "GET is cacheable" (is_cacheable `GET ) true;
Alcotest.(check bool) "HEAD is cacheable" (is_cacheable `HEAD) true;
Alcotest.(check bool) "POST is cacheable" (is_cacheable `POST) true;
Alcotest.(check bool) "PUT is cacheable" (is_cacheable `PUT ) false;
Alcotest.(check bool) "DELETE is cacheable" (is_cacheable `DELETE ) false;
Alcotest.(check bool) "CONNECT is cacheable" (is_cacheable `CONNECT) false;
Alcotest.(check bool) "OPTIONS is cacheable" (is_cacheable `OPTIONS) false;
Alcotest.(check bool) "TRACE is cacheable" (is_cacheable `TRACE ) false;
;;
let test_is_idempotent () =
Alcotest.(check bool) "GET is idempotent" (is_idempotent `GET ) true;
Alcotest.(check bool) "HEAD is idempotent" (is_idempotent `HEAD) true;
Alcotest.(check bool) "POST is idempotent" (is_idempotent `POST) false;
Alcotest.(check bool) "PUT is idempotent" (is_idempotent `PUT ) true;
Alcotest.(check bool) "DELETE is idempotent" (is_idempotent `DELETE ) true;
Alcotest.(check bool) "CONNECT is idempotent" (is_idempotent `CONNECT) false;
Alcotest.(check bool) "OPTIONS is idempotent" (is_idempotent `OPTIONS) true;
Alcotest.(check bool) "TRACE is idempotent" (is_idempotent `TRACE ) true;
;;
let tests =
[ "is_safe" , `Quick, test_is_safe
; "is_cacheable" , `Quick, test_is_cacheable
; "is_idempotent", `Quick, test_is_idempotent
]