The ValueCodec laws as reusable property rows: mix into a munit.ScalaCheckSuite and register per instance.
class MyCodecsSuite extends ScalaCheckSuite, ValueCodecLaws:
valueCodecLaws[UserId]("UserId") // canonical values from the Arbitrary
valueCodecNormalisation[HeaderName]("HeaderName", headerTexts)
Registers the round-trip and canonical-encode laws: decode(encode(a)) == Right(a) and one wire text per value. The generator must produce CANONICAL values - for a normalising type that means values as its companion constructs them, which an Arbitrary built from the companion's own of/ofUnsafe yields by construction.
Registers the round-trip and canonical-encode laws: decode(encode(a)) == Right(a) and one wire text per value. The generator must produce CANONICAL values - for a normalising type that means values as its companion constructs them, which an Arbitrary built from the companion's own of/ofUnsafe yields by construction.
Attributes
def valueCodecNormalisation[A](name: String, texts: Gen[String])(using codec: ValueCodec[A]): Unit
Registers the normalisation law over arbitrary wire text: an accepted input decodes to a value whose encoding is a fixed point - decode is idempotent through re-encoding. Rejected inputs are outside the law.
Registers the normalisation law over arbitrary wire text: an accepted input decodes to a value whose encoding is a fixed point - decode is idempotent through re-encoding. Rejected inputs are outside the law.