Skip to content

Commit

Permalink
Add a very simple test for Parser::to_linecol.
Browse files Browse the repository at this point in the history
This test shows that in some cases converting error offsets generated by
the parser to line and column numbers will panic ('arithmetic operation
overflowed') in debug mode, and return an incorrect column number in
release mode.
  • Loading branch information
alex-gulyas committed Aug 14, 2015
1 parent 13513f9 commit 0f07463
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/invalid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ fn run(toml: &str) {
let table = p.parse();
assert!(table.is_none());
assert!(p.errors.len() > 0);

// test Parser::to_linecol with the generated error offsets
for error in &p.errors {
p.to_linecol(error.lo);
p.to_linecol(error.hi);
}
}

macro_rules! test( ($name:ident, $toml:expr) => (
Expand Down

0 comments on commit 0f07463

Please sign in to comment.