aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-05-30 19:37:44 -0500
committerGitHub <noreply@github.com>2017-05-30 19:37:44 -0500
commit95e1c738467c87f4072ac29923e7df399ebfe9ea (patch)
tree0dc8202f51434c0179ea6cf9ea404caecb570741 /tests
parentdfe67d6c60ab96e80d02747f60d0635acc67f718 (diff)
parent2a6b365f7c931feb5e870d54c6d4a02e8aee75bf (diff)
downloadmilf-rs-95e1c738467c87f4072ac29923e7df399ebfe9ea.tar.gz
milf-rs-95e1c738467c87f4072ac29923e7df399ebfe9ea.zip
Merge pull request #183 from alanhdu/invalid_number
Better invalid number handling
Diffstat (limited to 'tests')
-rw-r--r--tests/invalid-encoder-misc.rs14
-rw-r--r--tests/invalid-misc.rs4
2 files changed, 18 insertions, 0 deletions
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));
+}
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");
}