<commit_before>open OUnit

let test_empty_packet = Osc.(Message {
  address = "/foo/bar";
  arguments = [];
})

let test_empty_string_arg = Osc.(Message {
  address = "/foo/bar";
  arguments = [
    String "";
  ];
})

let test_packet_with_args = Osc.(Message {
  address = "/foo/bar";
  arguments = [
    Blob "baz";
    String "quux";
    Int32 789l;
    Float32 123.456;
  ];
})

let test_packets = [
  "empty_packet", test_empty_packet;
  "empty_string_arg", test_empty_string_arg;
  "packet_with_args", test_packet_with_args;
]

let are_arguments_equal arg1 arg2 =
  let open Osc in
  match arg1, arg2 with
  | Blob a, Blob b -> a = b
  | String a, String b -> a = b
  | Int32 a, Int32 b -> a = b
  | Float32 a, Float32 b ->
    let diff = abs_float (a -. b) in
    diff <= 0.01
  | _, _ -> false

let string_of_argument = function
  | Osc.Blob s -> Printf.sprintf "Blob %s" s
  | Osc.String s -> Printf.sprintf "String %s" s
  | Osc.Int32 i -> Printf.sprintf "Int32 %ld" i
  | Osc.Float32 f -> Printf.sprintf "Float32 %f" f

let assert_messages_equal message1 message2 =
  let open Osc in<commit_msg>Add a test packet with an empty blob argument<commit_after>open OUnit

let test_empty_packet = Osc.(Message {
  address = "/foo/bar";
  arguments = [];
})

let test_empty_string_arg = Osc.(Message {
  address = "/foo/bar";
  arguments = [
    String "";
  ];
})

let test_empty_blob_arg = Osc.(Message {
  address = "/foo/bar";
  arguments = [
    Blob "";
  ];
})

let test_packet_with_args = Osc.(Message {
  address = "/foo/bar";
  arguments = [
    Blob "baz";
    String "quux";
    Int32 789l;
    Float32 123.456;
  ];
})

let test_packets = [
  "empty_packet", test_empty_packet;
  "empty_string_arg", test_empty_string_arg;
  "empty_blob_arg", test_empty_blob_arg;
  "packet_with_args", test_packet_with_args;
]

let are_arguments_equal arg1 arg2 =
  let open Osc in
  match arg1, arg2 with
  | Blob a, Blob b -> a = b
  | String a, String b -> a = b
  | Int32 a, Int32 b -> a = b
  | Float32 a, Float32 b ->
    let diff = abs_float (a -. b) in
    diff <= 0.01
  | _, _ -> false

let string_of_argument = function
  | Osc.Blob s -> Printf.sprintf "Blob %s" s
  | Osc.String s -> Printf.sprintf "String %s" s
  | Osc.Int32 i -> Printf.sprintf "Int32 %ld" i
  | Osc.Float32 f -> Printf.sprintf "Float32 %f" f

let assert_messages_equal message1 message2 =
  let open Osc in
{'fraction_non_alphanumeric': 0.13107202680067, 'fraction_numerical': 0.031825795644891124, 'mean_word_length': 2.9949832775919734, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5175023', 'n_tokens_mistral': 950, 'n_tokens_neox': 912, 'n_words': 246}