✅ improve coverage
This commit is contained in:
		
							parent
							
								
									b315fe484a
								
							
						
					
					
						commit
						33662417c1
					
				
					 3 changed files with 17 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -1434,7 +1434,7 @@ class binary_writer
 | 
			
		|||
                    return 'L';
 | 
			
		||||
                }
 | 
			
		||||
                // anything else is treated as high-precision number
 | 
			
		||||
                return 'H';
 | 
			
		||||
                return 'H'; // LCOV_EXCL_LINE
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            case value_t::number_unsigned:
 | 
			
		||||
| 
						 | 
				
			
			@ -1460,7 +1460,7 @@ class binary_writer
 | 
			
		|||
                    return 'L';
 | 
			
		||||
                }
 | 
			
		||||
                // anything else is treated as high-precision number
 | 
			
		||||
                return 'H';
 | 
			
		||||
                return 'H'; // LCOV_EXCL_LINE
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            case value_t::number_float:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14153,7 +14153,7 @@ class binary_writer
 | 
			
		|||
                    return 'L';
 | 
			
		||||
                }
 | 
			
		||||
                // anything else is treated as high-precision number
 | 
			
		||||
                return 'H';
 | 
			
		||||
                return 'H'; // LCOV_EXCL_LINE
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            case value_t::number_unsigned:
 | 
			
		||||
| 
						 | 
				
			
			@ -14179,7 +14179,7 @@ class binary_writer
 | 
			
		|||
                    return 'L';
 | 
			
		||||
                }
 | 
			
		||||
                // anything else is treated as high-precision number
 | 
			
		||||
                return 'H';
 | 
			
		||||
                return 'H'; // LCOV_EXCL_LINE
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            case value_t::number_float:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -797,12 +797,19 @@ TEST_CASE("UBJSON")
 | 
			
		|||
 | 
			
		||||
                SECTION("errors")
 | 
			
		||||
                {
 | 
			
		||||
                    std::vector<uint8_t> vec1 = {'H', 'i', 2, '1', 'A', '3'};
 | 
			
		||||
                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec1), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A", json::parse_error);
 | 
			
		||||
                    std::vector<uint8_t> vec2 = {'H', 'i', 2, '1', '.'};
 | 
			
		||||
                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec2), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1.", json::parse_error);
 | 
			
		||||
                    std::vector<uint8_t> vec3 = {'H', 2, '1', '0'};
 | 
			
		||||
                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec3), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x02", json::parse_error);
 | 
			
		||||
                    // error while parsing length
 | 
			
		||||
                    std::vector<uint8_t> vec0 = {'H', 'i'};
 | 
			
		||||
                    CHECK(json::from_ubjson(vec0, true, false).is_discarded());
 | 
			
		||||
                    // error while parsing string
 | 
			
		||||
                    std::vector<uint8_t> vec1 = {'H', 'i', '1'};
 | 
			
		||||
                    CHECK(json::from_ubjson(vec1, true, false).is_discarded());
 | 
			
		||||
 | 
			
		||||
                    std::vector<uint8_t> vec2 = {'H', 'i', 2, '1', 'A', '3'};
 | 
			
		||||
                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec2), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A", json::parse_error);
 | 
			
		||||
                    std::vector<uint8_t> vec3 = {'H', 'i', 2, '1', '.'};
 | 
			
		||||
                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec3), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1.", json::parse_error);
 | 
			
		||||
                    std::vector<uint8_t> vec4 = {'H', 2, '1', '0'};
 | 
			
		||||
                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec4), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x02", json::parse_error);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                SECTION("serialization")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue