From 0f0746396a67028d4a58071e7b1a6ae26c9f6954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Guly=C3=A1s?= Date: Fri, 14 Aug 2015 14:39:59 +0200 Subject: [PATCH] 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. --- tests/invalid.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/invalid.rs b/tests/invalid.rs index 3df4d02..e9a94e9 100644 --- a/tests/invalid.rs +++ b/tests/invalid.rs @@ -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) => (