summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-03-26 17:28:51 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-07-10 15:36:05 +0200
commit7e3a90f5c1ab96f63b00583463e865f2d4565b67 (patch)
treee499f2c675f9445ae348312c842d86e42a261974
parent74a0a809f642e2d212752c9ccb767d987c42302e (diff)
Add test whether float is the correct numbertest-float-vs-real-int
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--tests/floatint.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/floatint.rs b/tests/floatint.rs
new file mode 100644
index 0000000..0c1d1e5
--- /dev/null
+++ b/tests/floatint.rs
@@ -0,0 +1,20 @@
+extern crate config;
+use config::*;
+
+fn make() -> Config {
+ Config::default()
+ .merge(File::from_str(
+ r#"{"floatval": "9223372036854775807"}"#,
+ FileFormat::Json,
+ ))
+ .unwrap()
+ .clone()
+}
+
+#[test]
+fn test_invalid_float() {
+ let c = make();
+ let f = c.get_float("floatval").unwrap();
+ assert_eq!(format!("{}", f), format!("{}", 9223372036854775807 as i64));
+}
+