Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve assertions in tests #29

Open
Marcono1234 opened this issue Dec 3, 2023 · 0 comments
Open

Improve assertions in tests #29

Marcono1234 opened this issue Dec 3, 2023 · 0 comments
Labels
enhancement New feature or request internal Issue or pull request which is internal and has no user-visible effect

Comments

@Marcono1234
Copy link
Owner

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' value1.

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

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').

Footnotes

  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.

@Marcono1234 Marcono1234 added enhancement New feature or request internal Issue or pull request which is internal and has no user-visible effect labels Dec 3, 2023
Marcono1234 added a commit that referenced this issue Dec 23, 2023
This reads a bit more natural when left is the actual and right is the
expected value.

However, the tests still have the expected argument left, see also #29.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request internal Issue or pull request which is internal and has no user-visible effect
Projects
None yet
Development

No branches or pull requests

1 participant