Skip to content

Conversation

@jbangelo
Copy link
Contributor

@jbangelo jbangelo commented Oct 30, 2019

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:

  • The SBPMessage was not marked as public, so it's fields could not be accessed from outside the crate.
  • Several of the YAML specifications for tests contained values without a decimal point for float values. This meant that the generators for the tests would emit the literal values as integers. Rust doesn't allow these implicit type conversions, so the YAML was modified to contain values with a decimal point so the test generator knew to emit the correct floating point comparison.

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.

@jbangelo jbangelo requested a review from silverjam October 30, 2019 19:55
Copy link
Contributor

@silverjam silverjam left a 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!

@jbangelo jbangelo requested a review from silverjam November 1, 2019 04:03
@jbangelo jbangelo merged commit e7b4d5b into master Nov 1, 2019
@jbangelo jbangelo deleted the jbangelo/add-rust-test branch November 1, 2019 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants