Lines
100 %
Functions
Branches
use ron::{
de::from_str,
error::{Error, Position, SpannedError},
};
#[test]
fn test_hex() {
assert_eq!(from_str("0x507"), Ok(0x507));
assert_eq!(from_str("0x1A5"), Ok(0x1A5));
assert_eq!(from_str("0x53C537"), Ok(0x53C537));
assert_eq!(
from_str::<u8>("0x"),
Err(SpannedError {
code: Error::ExpectedInteger,
position: Position { line: 1, col: 3 },
})
);
from_str::<u8>("0x_1"),
code: Error::UnderscoreAtBeginning,
from_str::<u8>("0xFFF"),
code: Error::IntegerOutOfBounds,
position: Position { line: 1, col: 6 },
}
fn test_bin() {
assert_eq!(from_str("0b101"), Ok(0b101));
assert_eq!(from_str("0b001"), Ok(0b001));
assert_eq!(from_str("0b100100"), Ok(0b100100));
from_str::<u8>("0b"),
from_str::<u8>("0b_1"),
from_str::<u8>("0b111111111"),
position: Position { line: 1, col: 12 },
fn test_oct() {
assert_eq!(from_str("0o1461"), Ok(0o1461));
assert_eq!(from_str("0o051"), Ok(0o051));
assert_eq!(from_str("0o150700"), Ok(0o150700));
from_str::<u8>("0o"),
from_str::<u8>("0o_1"),
from_str::<u8>("0o77777"),
position: Position { line: 1, col: 8 },
fn test_dec() {
assert_eq!(from_str("1461"), Ok(1461));
assert_eq!(from_str("51"), Ok(51));
assert_eq!(from_str("150700"), Ok(150700));
from_str::<i8>("-_1"),
position: Position { line: 1, col: 2 },
from_str::<u8>("256"),
position: Position { line: 1, col: 4 },