serde-rs/test

Add assert_de_tokens_error examples for Compact and Readable representation

huxi opened this issue · 1 comments

huxi commented

I had a hard time finding out about how to use assert_de_tokens_error in combination with types having both readable and compact representation.

If one simply uses assert_de_tokens_error::<Foo> for a type Foo with both readable and compact representation, the following error message is provided:

Types which have different human-readable and compact representations 
must explicitly mark their test cases with `serde_test::Configure`

This makes sense in general but isn't really that helpful.

It took me way too long to realize that the correct calls to achieve this are assert_de_tokens_error::<Compact<Foo>> and assert_de_tokens_error::<Readable<Foo>>.

This, again, makes sense but isn't that obvious, especially given the original error message.

It would be nice to provide some examples for this use case in the documentation of assert_de_tokens_error.

Thanks! I agree this needs much better documentation and probably a better error message.