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

Protocol tests and floating point comparisons #1147

Open
david-perez opened this issue Feb 2, 2022 · 0 comments
Open

Protocol tests and floating point comparisons #1147

david-perez opened this issue Feb 2, 2022 · 0 comments

Comments

@david-perez
Copy link
Contributor

Server protocol tests are using the PartialEq implementation on floating point types because they assert_eq on the containing operation input shape.

Client protocol tests, on the other hand, always iterate over the shape's members and use aws_smithy_protocol_test::FloatEquals.

This trait differs in float’s default PartialEq implementation by considering all NaN values to be equal.

I stumbled upon this earlier in smithy-lang/smithy#1040 (comment). I think this fix is fair.

However, I don't see this trait being used recursively in the client tests i.e. the shape containing floating point types could be nested.

https://github.com/awslabs/smithy-rs/blob/4b8381b22c8d4b8eebea60bdc6a666bb75dece57/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/protocol/ProtocolTestGenerator.kt#L326-L335

david-perez added a commit that referenced this issue Feb 10, 2022
The client protocol tests use the
`aws_smithy_protocol_test::FloatEquals` for this [0].

Note we're only applying this to direct floating point shape members,
i.e. this commit _does not_ address #1147.

[0]: https://docs.rs/aws-smithy-protocol-test/latest/aws_smithy_protocol_test/trait.FloatEquals.html
david-perez added a commit that referenced this issue Feb 23, 2022
The client protocol tests use the
`aws_smithy_protocol_test::FloatEquals` for this [0].

Note we're only applying this to direct floating point shape members,
i.e. this commit _does not_ address #1147.

[0]: https://docs.rs/aws-smithy-protocol-test/latest/aws_smithy_protocol_test/trait.FloatEquals.html
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

No branches or pull requests

1 participant