@@ -134,6 +134,11 @@ class CBORScannerTests : TestState, std::source_location {
134134 return expect (std::move (loc), &Token::as_simple, expected, std::move (from));
135135 }
136136
137+ inline auto expect_float (std::source_location loc, std::uint64_t expected,
138+ vec_u8 from) noexcept {
139+ return expect (std::move (loc), &Token::as_float, expected, std::move (from));
140+ }
141+
137142public:
138143 inline auto success () const noexcept {
139144 return numFailed_ == 0 ;
@@ -463,17 +468,17 @@ class CBORScannerTests : TestState, std::source_location {
463468 return expect_simple (current (), 0 , {0xf8 , 0x00 });
464469 }
465470
466- TEST_CASE (decode_float) {
467- std::vector<std::uint8_t > test_vector{0xf9 , 0x01 , 0x02 };
468- auto result = consume (ScanState{}, test_vector);
469- auto [_, token] = result.as_complete ().value ();
470- if (token.as_float ().value () == 0x0102 ) {
471- return pass (current ().function_name ());
472- }
473- return fail (current ().function_name ());
471+ auto test_decode_float2 () noexcept {
472+ return expect_float (current (), 0 , {0xf9 , 0x00 , 0x00 });
473+ }
474+
475+ auto test_decode_float4 () noexcept {
476+ return expect_float (current (), 0 , {0xfa , 0x00 , 0x00 , 0x00 , 0x00 });
474477 }
475- catch (...) {
476- return fail (current ().function_name ());
478+
479+ auto test_decode_float8 () noexcept {
480+ return expect_float (current (), 0 ,
481+ {0xfb , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 });
477482 }
478483};
479484
@@ -540,6 +545,8 @@ int main(int argc, char *argv[]) {
540545 testSuite.test_decode_tag8 ();
541546 testSuite.test_decode_simple0 ();
542547 testSuite.test_decode_simple1 ();
543- testSuite.test_decode_float ();
548+ testSuite.test_decode_float2 ();
549+ testSuite.test_decode_float4 ();
550+ testSuite.test_decode_float8 ();
544551 return testSuite.failure ();
545552}
0 commit comments