Skip to content

Protocol tests and floating point comparisons #1147

Open
@david-perez

Description

@david-perez

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions