open Alcotest let hex_to_string hex = let len = String.length hex / 2 in let buf = Bytes.create len in for i = 0 to len - 1 do let c = int_of_string ("0x" ^ String.sub hex (i * 2) 2) in Bytes.set buf i (Char.chr c) done; Bytes.to_string buf let test_decompress_go_data () = let compressed = hex_to_string "00919461c3e60d0b1057dec861432604082a68d2cc01211144181074cacca103e28d19104cb45c0131e64d1b387234ce49f3c68d8b80" in match Swim.Lzw.decompress_lsb8 compressed with | Ok result -> check string "decompressed matches" "Hello, World! This is a test of LZW compression." result | Error e -> fail (Printf.sprintf "decompression failed: %s" (Swim.Lzw.error_to_string e)) let () = run "lzw" [ ("decompress", [ test_case "go_data" `Quick test_decompress_go_data ]) ]