Commits

Paweł Wieczorek committed f48cbf1 Draft

cleaning

  • Participants
  • Parent commits 8d2562c

Comments (0)

Files changed (1)

File tests/Test_parser.ml

 open Batteries
 open OUnit
 open Sip_types
+open Testdata_messages.Util
 
 (*********************************************************************************************************************
- * Parsing
+ * Helpers
  *)
-open Testdata_messages.Util
 
 let assert_str_equal msg a b =
     assert_equal ~msg:msg ~printer:String.quote a b
         ~printer:printer
         expected extracted
 
-let validate_extracted_field request conv revconv field extracted expected =
+let validate_extracted_field request conv revconv field =
     let actual_mime      = conv (request#header (String.lowercase field)) in
     let printer = String.quote -| revconv in
-    _validate_field printer actual_mime request revconv field extracted expected
+    _validate_field printer actual_mime request revconv field 
 
-let validate_extracted_field_option request conv revconv field extracted expected =
+let validate_extracted_field_option request conv revconv field =
     let actual_mime      = Option.map conv (request#header_option (String.lowercase field)) in
     let printer          = Option.map_default (String.quote -| revconv) "None" in
-    _validate_field printer actual_mime request revconv field extracted expected
+    _validate_field printer actual_mime request revconv field 
 
-let validate_extracted_field_all request conv revconv field extracted expected =
+let validate_extracted_field_all request conv revconv field =
     let actual_mime      = List.map conv (request#header_all (String.lowercase field)) in
     let printer          = String.concat "," -| List.map (String.quote -| revconv) in
-    _validate_field printer actual_mime request revconv field extracted expected
+    _validate_field printer actual_mime request revconv field 
+
+(*********************************************************************************************************************
+ * Checking message against description
+ *)
 
 let validate_message request = function
     | DescrMimeField (field, expected) ->
 
     | DescrSipVersion expected ->
         let extracted = request#sip_version in
-        assert_equal ~msg:"incorrect sip version" ~printer:string_of_sip_version expected extracted
+        assert_equal
+            ~msg:"incorrect sip version"
+            ~printer:string_of_sip_version
+            expected extracted
 
     | DescrSipMethod expected ->
         let extracted = request#sip_method in
-        assert_equal ~msg:"incorrect sip method" ~printer:string_of_sip_request_method expected extracted
+        assert_equal
+            ~msg:"incorrect sip method"
+            ~printer:string_of_sip_request_method
+            expected extracted
 
     | DescrUri expected ->
         let extracted = request#uri in
-        assert_equal ~msg:"incorrect reques uri" ~printer:string_of_sip_uri expected extracted
+        assert_equal
+            ~msg:"incorrect reques uri"
+            ~printer:string_of_sip_uri
+            expected extracted
 
     | DescrCseq expected ->
         let extracted = request#cseq in
             sip_address_of_string string_of_sip_address
             "contact" extracted expected
 
+(*********************************************************************************************************************
+ * Test generators
+ *)
+
 let valid_message_parse_test (title, buffer, descr) = 
     "valid message -- " ^ title >::
     begin fun () ->
         assert_raises Sip_parser.Invalid_sip_message (fun () -> Sip_parser.parse_request buffer)
     end
 
+(*********************************************************************************************************************
+ * Test suite
+ *)
+
 let test_suite = "Parser" >:::
       List.map valid_message_parse_test   Valid_messages.messages
     @ List.map invalid_message_parse_test Invalid_messages.messages