Skip to content

Commit

Permalink
feat: add more unit tests for float parsing
Browse files Browse the repository at this point in the history
the float parser change had removed some negative tests.

reintroduced some negative tests, and some more formatting
tests.
  • Loading branch information
louiscaron committed Aug 10, 2024
1 parent f0865ae commit 3a9da03
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion a2lfile/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ mod tests {

#[test]
fn parsing_numbers_test() {
let input_text = r##"0 0x1 1.0e+2 1000 0 0.1 0x11 1.0e+2"##;
let input_text = r##"0 0x1 1.0e+2 1000 0 0.1 0x11 1.0e+2 0X1f 0X2F 2F F"##;
let tokenresult = tokenizer::tokenize(&Filename::from("test_input"), 0, input_text);
assert!(tokenresult.is_ok());

Expand Down Expand Up @@ -1177,6 +1177,27 @@ mod tests {
assert!(res.is_ok());
let val = res.unwrap();
assert_eq!(val, 100f32);

// float: 0X1f
let res = parser.get_float(&context);
assert!(res.is_ok());
let val = res.unwrap();
assert_eq!(val, 31f32);

// float: 0X2F
let res = parser.get_float(&context);
assert!(res.is_ok());
let val = res.unwrap();
assert_eq!(val, 47f32);

// float: 2F
let res = parser.get_float(&context);
assert!(res.is_err());

// float: F
let res = parser.get_float(&context);
assert!(res.is_err());

}

#[test]
Expand Down

0 comments on commit 3a9da03

Please sign in to comment.