Paweł Wieczorek avatar Paweł Wieczorek committed 5ef1aba Draft

more tests

Comments (0)

Files changed (2)

  * TODO: Maybe Should I use some external library for parsing URI? Eh... crazy text format ;]
  *)
 
-type uri_scheme
+type sip_uri_scheme
     = URI_SCHEME_SIP
     | URI_SCHEME_SIPS
     | URI_SCHEME_TEL
-    | URI_SCHEME_Unknown of string
+    | UnknownUriScheme of string
 
-let string_of_uri_scheme = function
+let string_of_sip_uri_scheme = function
     | URI_SCHEME_SIP -> "sip"
     | URI_SCHEME_SIPS -> "sips"
     | URI_SCHEME_TEL -> "tel"
-    | URI_SCHEME_Unknown s -> s
+    | UnknownUriScheme s -> s
 
-let uri_scheme_of_string = function
+let sip_uri_scheme_of_string = function
     | "sip"  -> URI_SCHEME_SIP
     | "sips" -> URI_SCHEME_SIPS
-    | scheme -> URI_SCHEME_Unknown scheme
+    | scheme -> UnknownUriScheme scheme
 
 (*********************************************************************************************************************
  *)

tests/Test_sip_types.ml

         (sip_call_id_of_string, string_of_sip_call_id)
 
     let valid_data =
-        [
+        [ prepare_valid_case'
+            "f81d4fae-7dec-11d0-a765-00a0c91e6bf6@biloxi.com"
+            ( SipCallId("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@biloxi.com") )
+
+        ; prepare_valid_case'
+            "this is sparta"
+            ( SipCallId("this is sparta") )
         ]
 
     let invalid_data =
         ]
 
 end
+
 (*********************************************************************************************************************
  *)
 
 (*********************************************************************************************************************
  *)
 
+module Test_sip_uri_scheme = struct
+
+    type t = sip_uri_scheme
+
+    let converters =
+        (sip_uri_scheme_of_string, string_of_sip_uri_scheme)
+
+    let valid_data =
+        [ prepare_valid_case'
+            "sip"
+            URI_SCHEME_SIP
+
+        ; prepare_valid_case'
+            "sips"
+            URI_SCHEME_SIPS
+
+        ; prepare_valid_case'
+            "tel"
+            URI_SCHEME_TEL
+
+        ; prepare_valid_case'
+            "http"
+            (UnknownUriScheme "http")
+
+        ; prepare_valid_case'
+            "https"
+            (UnknownUriScheme "https")
+        ]
+
+    let invalid_data =
+        let prepare title = prepare_invalid_case' title "sip_uri_scheme_of_string" in
+        [ prepare "sip:"
+        ; prepare "sips:"
+        ; prepare "tel:"
+        ; prepare "http:"
+        ; prepare "https:"
+        ; prepare "sip "
+        ; prepare "si+p"
+        ; prepare "s@ip "
+        ; prepare "s*ip "
+        ; prepare "sip a"
+        ]
+
+end
+
+(*********************************************************************************************************************
+ *)
+
 module Test_sip_uri = struct
 
     type t = sip_uri
     ; 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_scheme     : 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 )
     ]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.