CCSDS Synchronization and Channel Coding (131.0-B, 231.0-B)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

scc: Fmt.pf/str, rename test_ functions in interop (merlint E200/E330)

+20 -20
+7 -7
lib/sync.ml
··· 19 19 | Bch_error of int (** BCH parity error at codeblock index *) 20 20 21 21 let pp_error ppf = function 22 - | Too_short -> Format.fprintf ppf "data too short" 23 - | Invalid_length n -> Format.fprintf ppf "invalid frame length: %d" n 24 - | Invalid_start_sequence -> Format.fprintf ppf "invalid CLTU start sequence" 25 - | Invalid_tail_sequence -> Format.fprintf ppf "invalid CLTU tail sequence" 26 - | Asm_not_found -> Format.fprintf ppf "ASM marker not found" 27 - | Frame_too_large n -> Format.fprintf ppf "frame too large: %d bytes" n 28 - | Bch_error n -> Format.fprintf ppf "BCH parity error at codeblock %d" n 22 + | Too_short -> Fmt.pf ppf "data too short" 23 + | Invalid_length n -> Fmt.pf ppf "invalid frame length: %d" n 24 + | Invalid_start_sequence -> Fmt.pf ppf "invalid CLTU start sequence" 25 + | Invalid_tail_sequence -> Fmt.pf ppf "invalid CLTU tail sequence" 26 + | Asm_not_found -> Fmt.pf ppf "ASM marker not found" 27 + | Frame_too_large n -> Fmt.pf ppf "frame too large: %d bytes" n 28 + | Bch_error n -> Fmt.pf ppf "BCH parity error at codeblock %d" n 29 29 30 30 (** {1 CLTU - Command Link Transmission Unit} 31 31
+12 -12
test/interop/dariol83/test.ml
··· 39 39 | Ok rows -> rows 40 40 | Error e -> Alcotest.failf "failed to parse cltu.csv: %a" Csvt.pp_error e 41 41 42 - let test_cltu_encode (r : cltu_row) () = 42 + let cltu_encode (r : cltu_row) () = 43 43 let tc_frame = bytes_of_hex r.tc_frame_hex in 44 44 let cltu = Scc.Sync.Cltu.encode tc_frame in 45 45 let got_hex = hex_of_bytes cltu in ··· 47 47 Alcotest.failf "%s: encode mismatch\n expected: %s\n got: %s" r.name 48 48 r.cltu_hex got_hex 49 49 50 - let test_cltu_decode (r : cltu_row) () = 50 + let cltu_decode (r : cltu_row) () = 51 51 let cltu = bytes_of_hex r.cltu_hex in 52 52 match Scc.Sync.Cltu.decode cltu with 53 53 | Error e -> Alcotest.failf "%s: decode failed: %a" r.name Scc.Sync.pp_error e ··· 68 68 "%s: decoded prefix mismatch\n expected: %s\n got: %s" r.name 69 69 r.tc_frame_hex prefix_hex 70 70 71 - let test_cltu_roundtrip (r : cltu_row) () = 71 + let cltu_roundtrip (r : cltu_row) () = 72 72 let tc_frame = bytes_of_hex r.tc_frame_hex in 73 73 let cltu = Scc.Sync.Cltu.encode tc_frame in 74 74 match Scc.Sync.Cltu.decode cltu with ··· 109 109 | Error e -> 110 110 Alcotest.failf "failed to parse randomizer.csv: %a" Csvt.pp_error e 111 111 112 - let test_randomize (r : rand_row) () = 112 + let randomize (r : rand_row) () = 113 113 let input = bytes_of_hex r.input_hex in 114 114 let rand = Scc.Coding.Randomizer.create () in 115 115 Scc.Coding.Randomizer.apply rand input 0 (Bytes.length input); ··· 118 118 Alcotest.failf "%s: randomize mismatch\n expected: %s\n got: %s" 119 119 r.name r.randomized_hex got_hex 120 120 121 - let test_derandomize (r : rand_row) () = 121 + let derandomize (r : rand_row) () = 122 122 (* Applying the randomizer twice should return the original. *) 123 123 let data = bytes_of_hex r.randomized_hex in 124 124 let rand = Scc.Coding.Randomizer.create () in ··· 128 128 Alcotest.failf "%s: derandomize mismatch\n expected: %s\n got: %s" 129 129 r.name r.input_hex got_hex 130 130 131 - let test_randomize_string (r : rand_row) () = 131 + let randomize_string (r : rand_row) () = 132 132 let input = Bytes.to_string (bytes_of_hex r.input_hex) in 133 133 let rand = Scc.Coding.Randomizer.create () in 134 134 let got = Scc.Coding.Randomizer.apply_string rand input in ··· 225 225 ( "cltu-encode", 226 226 List.map 227 227 (fun (r : cltu_row) -> 228 - Alcotest.test_case r.name `Quick (test_cltu_encode r)) 228 + Alcotest.test_case r.name `Quick (cltu_encode r)) 229 229 cltu_rows ); 230 230 ( "cltu-decode", 231 231 List.map 232 232 (fun (r : cltu_row) -> 233 - Alcotest.test_case r.name `Quick (test_cltu_decode r)) 233 + Alcotest.test_case r.name `Quick (cltu_decode r)) 234 234 cltu_rows ); 235 235 ( "cltu-roundtrip", 236 236 List.map 237 237 (fun (r : cltu_row) -> 238 - Alcotest.test_case r.name `Quick (test_cltu_roundtrip r)) 238 + Alcotest.test_case r.name `Quick (cltu_roundtrip r)) 239 239 cltu_rows ); 240 240 ( "randomize", 241 241 List.map 242 242 (fun (r : rand_row) -> 243 - Alcotest.test_case r.name `Quick (test_randomize r)) 243 + Alcotest.test_case r.name `Quick (randomize r)) 244 244 rand_rows ); 245 245 ( "derandomize", 246 246 List.map 247 247 (fun (r : rand_row) -> 248 - Alcotest.test_case r.name `Quick (test_derandomize r)) 248 + Alcotest.test_case r.name `Quick (derandomize r)) 249 249 rand_rows ); 250 250 ( "randomize-string", 251 251 List.map 252 252 (fun (r : rand_row) -> 253 - Alcotest.test_case r.name `Quick (test_randomize_string r)) 253 + Alcotest.test_case r.name `Quick (randomize_string r)) 254 254 rand_rows ); 255 255 ( "rs-encode", 256 256 List.map
+1 -1
test/test_sync.ml
··· 394 394 (** Test pp_error produces meaningful content for each error variant. Check for 395 395 key substrings (field names and values), not just non-empty output. *) 396 396 let test_pp_error () = 397 - let pp e = Format.asprintf "%a" Scc.Sync.pp_error e in 397 + let pp e = Fmt.str "%a" Scc.Sync.pp_error e in 398 398 (* Too_short: check exact expected message *) 399 399 Alcotest.(check string) "Too_short" "data too short" (pp Scc.Sync.Too_short); 400 400 (* Invalid_length: check it contains "invalid" and the numeric value *)