summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRyan Leckey <ryan@launchbadge.com>2017-06-13 02:21:46 -0700
committerRyan Leckey <ryan@launchbadge.com>2017-06-13 02:21:46 -0700
commitab0d8cb9aa107c8d561f3c188e6cbf472a7df23b (patch)
tree80545ea4305763bbf47a9bd33f4da99d6c9b985b /tests
parentbabd49242c04e783ae27ea159e2bc42d24490520 (diff)
:shirt: Fix clippy warnings
Diffstat (limited to 'tests')
-rw-r--r--tests/get_scalar.rs42
-rw-r--r--tests/get_struct.rs12
-rw-r--r--tests/merge.rs8
3 files changed, 32 insertions, 30 deletions
diff --git a/tests/get_scalar.rs b/tests/get_scalar.rs
index 08d8507..5d54e18 100644
--- a/tests/get_scalar.rs
+++ b/tests/get_scalar.rs
@@ -14,33 +14,33 @@ fn make() -> Config {
fn test_scalar() {
let c = make();
- assert!(c.get("debug").ok() == Some(true));
- assert!(c.get("production").ok() == Some(false));
+ assert_eq!(c.get("debug").ok(), Some(true));
+ assert_eq!(c.get("production").ok(), Some(false));
}
#[test]
fn test_scalar_type_loose() {
let c = make();
- assert!(c.get("debug").ok() == Some(true));
- assert!(c.get("debug").ok() == Some("true".to_string()));
- assert!(c.get("debug").ok() == Some(1));
- assert!(c.get("debug").ok() == Some(1.0));
-
- assert!(c.get("debug_s").ok() == Some(true));
- assert!(c.get("debug_s").ok() == Some("true".to_string()));
- assert!(c.get("debug_s").ok() == Some(1));
- assert!(c.get("debug_s").ok() == Some(1.0));
-
- assert!(c.get("production").ok() == Some(false));
- assert!(c.get("production").ok() == Some("false".to_string()));
- assert!(c.get("production").ok() == Some(0));
- assert!(c.get("production").ok() == Some(0.0));
-
- assert!(c.get("production_s").ok() == Some(false));
- assert!(c.get("production_s").ok() == Some("false".to_string()));
- assert!(c.get("production_s").ok() == Some(0));
- assert!(c.get("production_s").ok() == Some(0.0));
+ assert_eq!(c.get("debug").ok(), Some(true));
+ assert_eq!(c.get("debug").ok(), Some("true".to_string()));
+ assert_eq!(c.get("debug").ok(), Some(1));
+ assert_eq!(c.get("debug").ok(), Some(1.0));
+
+ assert_eq!(c.get("debug_s").ok(), Some(true));
+ assert_eq!(c.get("debug_s").ok(), Some("true".to_string()));
+ assert_eq!(c.get("debug_s").ok(), Some(1));
+ assert_eq!(c.get("debug_s").ok(), Some(1.0));
+
+ assert_eq!(c.get("production").ok(), Some(false));
+ assert_eq!(c.get("production").ok(), Some("false".to_string()));
+ assert_eq!(c.get("production").ok(), Some(0));
+ assert_eq!(c.get("production").ok(), Some(0.0));
+
+ assert_eq!(c.get("production_s").ok(), Some(false));
+ assert_eq!(c.get("production_s").ok(), Some("false".to_string()));
+ assert_eq!(c.get("production_s").ok(), Some(0));
+ assert_eq!(c.get("production_s").ok(), Some(0.0));
}
#[test]
diff --git a/tests/get_struct.rs b/tests/get_struct.rs
index 705c769..57e4bb2 100644
--- a/tests/get_struct.rs
+++ b/tests/get_struct.rs
@@ -1,10 +1,12 @@
extern crate config;
extern crate serde;
+extern crate float_cmp;
#[macro_use]
extern crate serde_derive;
use config::*;
+use float_cmp::ApproxEqUlps;
#[derive(Debug, Deserialize)]
struct Place {
@@ -39,11 +41,11 @@ fn test_file_struct() {
// Deserialize the entire file as single struct
let s: Settings = c.deserialize().unwrap();
- assert_eq!(s.debug, 1.0);
+ assert!(s.debug.approx_eq_ulps(&1.0, 2));
assert_eq!(s.production, Some("false".to_string()));
assert_eq!(s.place.name, "Torre di Pisa");
- assert_eq!(s.place.longitude, 43.7224985);
- assert_eq!(s.place.latitude, 10.3970522);
+ assert!(s.place.longitude.approx_eq_ulps(&43.7224985, 2));
+ assert!(s.place.latitude.approx_eq_ulps(&10.3970522, 2));
assert_eq!(s.place.favorite, false);
assert_eq!(s.place.reviews, 3866);
assert_eq!(s.place.rating, Some(4.5));
@@ -59,8 +61,8 @@ fn test_scalar_struct() {
let p: Place = c.get("place").unwrap();
assert_eq!(p.name, "Torre di Pisa");
- assert_eq!(p.longitude, 43.7224985);
- assert_eq!(p.latitude, 10.3970522);
+ assert!(p.longitude.approx_eq_ulps(&43.7224985, 2));
+ assert!(p.latitude.approx_eq_ulps(&10.3970522, 2));
assert_eq!(p.favorite, false);
assert_eq!(p.reviews, 3866);
assert_eq!(p.rating, Some(4.5));
diff --git a/tests/merge.rs b/tests/merge.rs
index df4ace8..4a42d6a 100644
--- a/tests/merge.rs
+++ b/tests/merge.rs
@@ -17,8 +17,8 @@ fn make() -> Config {
fn test_merge() {
let c = make();
- assert!(c.get("debug").ok() == Some(false));
- assert!(c.get("production").ok() == Some(true));
- assert!(c.get("place.creator.name").ok() == Some("Somebody New".to_string()));
- assert!(c.get("place.rating").ok() == Some(4.9));
+ assert_eq!(c.get("debug").ok(), Some(false));
+ assert_eq!(c.get("production").ok(), Some(true));
+ assert_eq!(c.get("place.creator.name").ok(), Some("Somebody New".to_string()));
+ assert_eq!(c.get("place.rating").ok(), Some(4.9));
}