aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gulyás <gulyas.alex@gmail.com>2015-08-14 14:39:59 +0200
committerAlex Gulyás <gulyas.alex@gmail.com>2015-08-14 14:39:59 +0200
commit0f0746396a67028d4a58071e7b1a6ae26c9f6954 (patch)
tree456ad301ee799c34c6590d6f58bff2803bf3bf99
parent13513f95b607949b071b484a09701a7662395bab (diff)
downloadmilf-rs-0f0746396a67028d4a58071e7b1a6ae26c9f6954.tar.gz
milf-rs-0f0746396a67028d4a58071e7b1a6ae26c9f6954.zip
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.
-rw-r--r--tests/invalid.rs6
1 files changed, 6 insertions, 0 deletions
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) => (