diff --git a/Cargo.lock b/Cargo.lock index 1c4c1aec513..1711f0b65f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -429,15 +429,6 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" -[[package]] -name = "float-cmp" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8" -dependencies = [ - "num-traits", -] - [[package]] name = "fnv" version = "1.0.7" @@ -514,7 +505,6 @@ dependencies = [ "curl", "curl-sys", "encoding", - "float-cmp", "glob", "hex", "hex-literal", @@ -542,7 +532,6 @@ name = "hurl_core" version = "6.0.0-SNAPSHOT" dependencies = [ "colored", - "float-cmp", "libxml", "regex", ] diff --git a/packages/hurl/Cargo.toml b/packages/hurl/Cargo.toml index 8c806b93b05..a677d05a0ee 100644 --- a/packages/hurl/Cargo.toml +++ b/packages/hurl/Cargo.toml @@ -24,7 +24,6 @@ clap = { version = "4.5.20", features = ["cargo", "string", "wrap_help"] } curl = "0.4.47" curl-sys = "0.4.77" encoding = "0.2.33" -float-cmp = "0.10.0" glob = "0.3.1" hex = "0.4.3" hex-literal = "0.4.1" diff --git a/packages/hurl/src/jsonpath/eval/selector.rs b/packages/hurl/src/jsonpath/eval/selector.rs index 71e0ba7e0d0..0728483f9c3 100644 --- a/packages/hurl/src/jsonpath/eval/selector.rs +++ b/packages/hurl/src/jsonpath/eval/selector.rs @@ -16,8 +16,6 @@ * */ -use float_cmp::approx_eq; - use crate::jsonpath::ast::{Predicate, PredicateFunc, Selector, Slice}; use crate::jsonpath::JsonpathResult; @@ -154,8 +152,8 @@ impl Predicate { match (value, self.func.clone()) { (_, PredicateFunc::KeyExist) => true, (serde_json::Value::Number(v), PredicateFunc::Equal(ref num)) => { - approx_eq!(f64, v.as_f64().unwrap(), num.to_f64(), ulps = 2) - } //v.as_f64().unwrap() == num.to_f64(), + (v.as_f64().unwrap() - num.to_f64()).abs() < f64::EPSILON + } (serde_json::Value::Number(v), PredicateFunc::GreaterThan(ref num)) => { v.as_f64().unwrap() > num.to_f64() } @@ -176,7 +174,7 @@ impl Predicate { v != *s } (serde_json::Value::Number(v), PredicateFunc::NotEqual(ref num)) => { - !approx_eq!(f64, v.as_f64().unwrap(), num.to_f64(), ulps = 2) + (v.as_f64().unwrap() - num.to_f64()).abs() >= f64::EPSILON } (serde_json::Value::Bool(v), PredicateFunc::EqualBool(ref s)) => v == *s, _ => false, diff --git a/packages/hurl_core/Cargo.toml b/packages/hurl_core/Cargo.toml index cb0b064eed2..6114d6ec633 100644 --- a/packages/hurl_core/Cargo.toml +++ b/packages/hurl_core/Cargo.toml @@ -11,7 +11,6 @@ repository = "https://github.com/Orange-OpenSource/hurl" [dependencies] colored = "2.1.0" -float-cmp = "0.10.0" libxml = "0.3.3" regex = "1.11.1"