Add a very simple test for Parser::to_linecol.
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.
This commit is contained in:
parent
13513f95b6
commit
0f0746396a
|
@ -7,6 +7,12 @@ fn run(toml: &str) {
|
||||||
let table = p.parse();
|
let table = p.parse();
|
||||||
assert!(table.is_none());
|
assert!(table.is_none());
|
||||||
assert!(p.errors.len() > 0);
|
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) => (
|
macro_rules! test( ($name:ident, $toml:expr) => (
|
||||||
|
|
Loading…
Reference in a new issue