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

protocoltest: rpcv2cbor: add float16 upcast tests #2291

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions smithy-protocol-tests/model/rpcv2Cbor/float16.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
$version: "2.0"

namespace smithy.protocoltests.rpcv2Cbor

use smithy.protocols#rpcv2Cbor
use smithy.test#httpResponseTests

// Verifies that clients can upcast float16s in responses.
@tags(["client-only"])
operation Float16 {
output: Float16Output
}

apply Float16 @httpResponseTests([
{
id: "RpcV2CborFloat16Inf",
documentation: "Ensures that clients can correctly parse float16 +Inf.",
protocol: rpcv2Cbor,
code: 200,
// https://cbor.nemo157.com/?type=hex&value=a16576616c7565f97c00
body: "oWV2YWx1Zfl8AA==",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
},
params: { value: "Infinity" }
bodyMediaType: "application/cbor",
appliesTo: "client"
},
{
id: "RpcV2CborFloat16NegInf",
documentation: "Ensures that clients can correctly parse float16 -Inf.",
protocol: rpcv2Cbor,
code: 200,
// https://cbor.nemo157.com/?type=hex&value=a16576616c7565f9fc00
body: "oWV2YWx1Zfn8AA==",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
},
params: { value: "-Infinity" }
bodyMediaType: "application/cbor",
appliesTo: "client"
},
{
id: "RpcV2CborFloat16LSBNaN",
documentation: "Ensures that clients can correctly parse float16 NaN with high LSB.",
protocol: rpcv2Cbor,
code: 200,
// https://cbor.nemo157.com/?type=hex&value=a16576616c7565f97c01
body: "oWV2YWx1Zfl8AQ==",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
},
params: { value: "NaN" }
bodyMediaType: "application/cbor",
appliesTo: "client"
},
{
id: "RpcV2CborFloat16MSBNaN",
documentation: "Ensures that clients can correctly parse float16 NaN with high MSB.",
protocol: rpcv2Cbor,
code: 200,
// https://cbor.nemo157.com/?type=hex&value=a16576616c7565f97e00
body: "oWV2YWx1Zfl+AA==",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
},
params: { value: "NaN" }
bodyMediaType: "application/cbor",
appliesTo: "client"
},
{
id: "RpcV2CborFloat16Subnormal",
documentation: "Ensures that clients can correctly parse a subnormal float16.",
protocol: rpcv2Cbor,
code: 200,
// https://cbor.nemo157.com/?type=hex&value=a16576616c7565f90050
body: "oWV2YWx1ZfkAUA==",
headers: {
"smithy-protocol": "rpc-v2-cbor",
"Content-Type": "application/cbor"
},
params: { value: 0.00000476837158203125 } // 1.25 * 2^-18
bodyMediaType: "application/cbor",
appliesTo: "client"
}
])

structure Float16Output {
value: Double
}
3 changes: 2 additions & 1 deletion smithy-protocol-tests/model/rpcv2Cbor/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ service RpcV2Protocol {
GreetingWithErrors,
FractionalSeconds,
OperationWithDefaults,
SparseNullsOperation
SparseNullsOperation,
Float16
]
}

Expand Down
Loading