Commits

Paweł Wieczorek committed 8bc3803 Draft

more tests

  • Participants
  • Parent commits dd373c0

Comments (0)

Files changed (2)

File src/Sip_types.ml

 let sip_cseq_of_string s = 
     try
         let (word, index) = Sip_utils.find_word 0 s in
-        let rest          = String.slice ~first:index s in
+        let rest          = String.slice ~first:(succ index) s in
         SipCseq (Int32.of_string word, sip_request_method_of_string rest)
     with _ ->
         failwith "sip_cseq_of_string"

File tests/Test_sip_types.ml

 let prepare_invalid_case title failmsg input = (title, failmsg, input)
 let prepare_invalid_case' title failmsg = (String.quote title, failmsg, title)
 
+let combine_invalid_cases' combine failmsg (title1, _, input1) (title2, _, input2) =
+    ("combine (" ^ title1 ^ ") with " ^ "(" ^ title2 ^ ")", failmsg, combine input1 input2)
+
 module type Test_for_type_converters = sig
 
     type t
 end
 
 (*********************************************************************************************************************
+ * Some data
+ *)
+
+module SomeData = struct
+
+    let list_int32 =
+        [ Int32.of_int 454
+        ; Int32.of_int 34
+        ; Int32.of_int 12345
+        ]
+
+
+end
+
+(*********************************************************************************************************************
  * SIP version
  *)
 
-module Test_sip_version : Test_for_type_converters = struct
+module Test_sip_version = struct
 
     type t = sip_version
 
 (*********************************************************************************************************************
  *)
 
-module Test_sip_request_method : Test_for_type_converters = struct
+module Test_sip_request_method = struct
 
     type t = sip_request_method
 
         ; prepare_valid_case'
             "OPTION"
             (UnknownRequestMethod "OPTION")
+
+        ; prepare_valid_case'
+            "BYE"
+            BYE
+
+        ; prepare_valid_case'
+            "PUBLISH"
+            PUBLISH
+
+        ; prepare_valid_case'
+            "SUBSCRIBE"
+            SUBSCRIBE
+
+        ; prepare_valid_case'
+            "NOTIFY"
+            NOTIFY
+
+        ; prepare_valid_case'
+            "INFO"
+            INFO
+
+        ; prepare_valid_case'
+            "REFER"
+            REFER
+
+        ; prepare_valid_case'
+            "UPDATE"
+            UPDATE
+
         ]
 
     let invalid_data =
         ; prepare " INVITE"
         ; prepare " a b c"
         ; prepare "INVITE "
+        ; prepare "17"
+        ; prepare " 18"
+        ; prepare "19 "
+        ; prepare " 20 "
+        ] 
+
+
+end
+
+(*********************************************************************************************************************
+ *)
+
+module Test_sip_cseq = struct
+
+    type t = sip_cseq
+
+    let converters =
+        (sip_cseq_of_string, string_of_sip_cseq)
+
+    let valid_data =
+        [ prepare_valid_case'
+            "1234 INVITE"
+            (SipCseq (Int32.of_int 1234, INVITE))
+
+        ; prepare_valid_case'
+            "1235 INVITE"
+            (SipCseq (Int32.of_int 1235, INVITE))
+
+        ; prepare_valid_case'
+            "1235 REGISTER"
+            (SipCseq (Int32.of_int 1235, REGISTER))
+
+        ; prepare_valid_case'
+            "1235 BYE"
+            (SipCseq (Int32.of_int 1235, BYE))
+
+        ; prepare_valid_case'
+            "42 OPTIONS"
+            (SipCseq (Int32.of_int 42, OPTIONS))
+
+        ; prepare_valid_case'
+            "45 OPTION"
+            (SipCseq (Int32.of_int 45, UnknownRequestMethod "OPTION"))
+        ]
+
+    let invalid_data =
+        let prepare title = prepare_invalid_case' title "sip_cseq_of_string" in
+        [ prepare "OPTION"
+        ; prepare "OPTION 42"
+        ; prepare "12 42"
+        ] 
+
+end
+
+(*********************************************************************************************************************
+ *)
+
+module Test_sip_call_id = struct
+
+    type t = sip_call_id
+
+    let converters =
+        (sip_call_id_of_string, string_of_sip_call_id)
+
+    let valid_data =
+        [
+        ]
+
+    let invalid_data =
+        [
+        ]
+
+end
+(*********************************************************************************************************************
+ *)
+
+module Test_sip_via = struct
+
+    type t = sip_via
+
+    let converters =
+        (sip_via_of_string, string_of_sip_via)
+
+    let valid_data =
+        [
+        ]
+
+    let invalid_data =
+        [
         ]
 
 end
 (*********************************************************************************************************************
  *)
 
+module Test_sip_uri = struct
+
+    type t = sip_uri
+
+    let converters =
+        (sip_uri_of_string, string_of_sip_uri)
+
+    let valid_data =
+        [
+        ]
+
+    let invalid_data =
+        [
+        ]
+
+end
+
+(*********************************************************************************************************************
+ *)
+
+module Test_sip_address = struct
+
+    type t = sip_address
+
+    let converters =
+        (sip_address_of_string, string_of_sip_address)
+
+    let valid_data =
+        [
+        ]
+
+    let invalid_data =
+        [
+        ]
+
+end
+
 (*********************************************************************************************************************
  *)
 
 let test_suite = "Types" >::: List.concat
     [ generate_tests_from_module (module Test_sip_version        : Test_for_type_converters )
     ; generate_tests_from_module (module Test_sip_request_method : Test_for_type_converters )
+    ; generate_tests_from_module (module Test_sip_cseq           : Test_for_type_converters )
+    ; generate_tests_from_module (module Test_sip_call_id        : Test_for_type_converters )
+    ; generate_tests_from_module (module Test_sip_via            : Test_for_type_converters )
+    ; generate_tests_from_module (module Test_sip_uri            : Test_for_type_converters )
+    ; generate_tests_from_module (module Test_sip_address        : Test_for_type_converters )
     ]