-
Notifications
You must be signed in to change notification settings - Fork 97
Add unit tests for Rust #745
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
silverjam
suggested changes
Oct 31, 2019
Contributor
silverjam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits, in general looks good!
silverjam
approved these changes
Nov 1, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds generation of the test cases for Rust. The tests are built and run as a part of the typical build process for the rust bindings. I took the route of generating the tests instead of writing tests that read and process the YAML directly because of Rust's lack of reflection it seemed difficult to do a member wise comparison of the values without either learning to write a macro or autogenerating at least some part of the tests.
A couple of additional minor changes were made to fix issues found while implementing these tests:
SBPMessagewas not marked as public, so it's fields could not be accessed from outside the crate.The template for the tests were based on the existing C test template. Besides the syntactic changes the floating point comparisons were changed significantly to be more strict. The difference between the literal value and the unpacked value are compared against a a scaled multiple of the Epsilon of the floating point type. This should make sure that our unpacked floating point values are correct to within about 5 counts of the original value specified in the YAML. In addition the test generator now emits the expected floating point literals to 17 decimal places to ensure the literal is precise enough.