(** Tests for Types module conversions *) let test_key_string_roundtrip () = let open Lithos.Types in let original = "hello_world" in let key = key_of_string original in let result = string_of_key key in Alcotest.(check string) "key roundtrip" original result ;; let test_value_string_roundtrip () = let open Lithos.Types in let original = "test_value_123" in let value = value_of_string original in let result = string_of_value value in Alcotest.(check string) "value string roundtrip" original result ;; let test_value_bytes_roundtrip () = let open Lithos.Types in let original = Bytes.of_string "binary_data" in let value = value_of_bytes original in let result = bytes_of_value value in Alcotest.(check bool) "value bytes roundtrip" true (Bytes.equal original result) ;; let test_empty_key () = let open Lithos.Types in let key = key_of_string "" in let result = string_of_key key in Alcotest.(check string) "empty key" "" result ;; let test_empty_value () = let open Lithos.Types in let value = value_of_string "" in let result = string_of_value value in Alcotest.(check string) "empty value" "" result ;; let test_binary_data () = let open Lithos.Types in let original = Bytes.of_string "\x00\x01\x02\xff\xfe\xfd" in let value = value_of_bytes original in let result = bytes_of_value value in Alcotest.(check bool) "binary data preservation" true (Bytes.equal original result) ;; let test_value_length () = let open Lithos.Types in let original = "test" in let value = value_of_string original in let len = Bigarray.Array1.dim value in Alcotest.(check int) "value length" (String.length original) len ;; let suite = [ "key_string_roundtrip", `Quick, test_key_string_roundtrip ; "value_string_roundtrip", `Quick, test_value_string_roundtrip ; "value_bytes_roundtrip", `Quick, test_value_bytes_roundtrip ; "empty_key", `Quick, test_empty_key ; "empty_value", `Quick, test_empty_value ; "binary_data", `Quick, test_binary_data ; "value_length", `Quick, test_value_length ] ;;