Marcono1234 / struson

Streaming JSON reader and writer written in Rust
https://crates.io/crates/struson
Apache License 2.0
64 stars 6 forks source link

Improve assertions in tests #29

Open Marcono1234 opened 11 months ago

Marcono1234 commented 11 months ago

Problem solved by the enhancement

Currently the tests use the standard assert macros, e.g. assert_eq. This make it difficult to see the difference in longer strings and their use of the terms 'left' and 'right' can be confusing when it is not immediately clear which is the 'expected' and which the 'actual' value[^1].

Additionally the handcrafted assertion helper functions and macros can produce confusing or verbose backtraces.

[^1]: Currently the code tries to have the 'expected' first and then the 'actual' (i.e. 'left=expected', 'right=actual'), but it might not be consistent. And in case of test failures this meaning is not obvious from the failure message.

Enhancement description

Use a more powerful assertion library, see for example:

Blog posts:

But check their maintenance status and how widely they are used.

Also try to clean up and improve the helper assertion functions and macros used in the tests of this project.

Alternatives / workarounds

Just try to clean up and improve the assertion code and make sure that the 'left' and 'right' arguments consistently have the same meaning (either 'expected' or 'actual').