From 3322bcd086399a658253e119323f4b4c44aa91ff Mon Sep 17 00:00:00 2001 From: Alan Du Date: Wed, 31 May 2017 00:07:15 +0100 Subject: Error when parsing numbers outside of f64's range --- tests/invalid-misc.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/invalid-misc.rs b/tests/invalid-misc.rs index 53f625e..bb70b97 100644 --- a/tests/invalid-misc.rs +++ b/tests/invalid-misc.rs @@ -10,4 +10,8 @@ fn bad() { bad("a = 1__1"); bad("a = 1_"); bad("''"); + bad("a = nan"); + bad("a = -inf"); + bad("a = inf"); + bad("a = 9e99999"); } -- cgit v1.2.3 From 2a6b365f7c931feb5e870d54c6d4a02e8aee75bf Mon Sep 17 00:00:00 2001 From: Alan Du Date: Wed, 31 May 2017 00:30:19 +0100 Subject: Error when trying to serialize invalid float --- tests/invalid-encoder-misc.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/invalid-encoder-misc.rs (limited to 'tests') diff --git a/tests/invalid-encoder-misc.rs b/tests/invalid-encoder-misc.rs new file mode 100644 index 0000000..272f58f --- /dev/null +++ b/tests/invalid-encoder-misc.rs @@ -0,0 +1,14 @@ +extern crate toml; + +use std::f64; + +#[test] +fn test_invalid_float_encode() { + fn bad(value: toml::Value) { + assert!(toml::to_string(&value).is_err()); + } + + bad(toml::Value::Float(f64::INFINITY)); + bad(toml::Value::Float(f64::NEG_INFINITY)); + bad(toml::Value::Float(f64::NAN)); +} -- cgit v1.2.3