Skip to content

Tests: generate values programmatically rather than cryptically

The following discussion from !11 (merged) should be addressed:

  • @raphael-proust started a discussion: (+1 comment)

    The only hold up on my side is that I need to convince myself that the byte sequences that are fed to the failing tests are indeed supposed to be failing.

    I'm thinking of replacing those byte literals by constructed values. E.g.,

          ( "array.truncated",
            `Quick,
            binary
              ~expected:not_enough_data
              (array ~max_length:1 int8)
              (let b = Binary.to_bytes (array int8) [|0|] in
               Bytes.sub b 0 (Bytes.length b - 2)) );

    The idea being: you first generate a value that is valid by construction and then you twist that value out of validity in a very obvious way.

    Comments?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information