aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/common_test.rs8
-rw-r--r--tests/d2s_table_test.rs9
-rw-r--r--tests/d2s_test.rs10
-rw-r--r--tests/f2s_test.rs8
-rw-r--r--tests/s2d_test.rs37
-rw-r--r--tests/s2f_test.rs33
6 files changed, 105 insertions, 0 deletions
diff --git a/tests/common_test.rs b/tests/common_test.rs
index a6010e9..2f05b33 100644
--- a/tests/common_test.rs
+++ b/tests/common_test.rs
@@ -19,6 +19,14 @@
// KIND, either express or implied.
#![allow(dead_code)]
+#![allow(
+ clippy::approx_constant,
+ clippy::cast_possible_wrap,
+ clippy::cast_sign_loss,
+ clippy::excessive_precision,
+ clippy::unreadable_literal,
+ clippy::wildcard_imports
+)]
#[path = "../src/common.rs"]
mod common;
diff --git a/tests/d2s_table_test.rs b/tests/d2s_table_test.rs
index aa45c55..dce1be3 100644
--- a/tests/d2s_table_test.rs
+++ b/tests/d2s_table_test.rs
@@ -19,6 +19,15 @@
// KIND, either express or implied.
#![allow(dead_code)]
+#![allow(
+ clippy::cast_lossless,
+ clippy::cast_possible_truncation,
+ clippy::cast_possible_wrap,
+ clippy::cast_sign_loss,
+ clippy::unreadable_literal,
+ clippy::unseparated_literal_suffix,
+ clippy::wildcard_imports
+)]
#[path = "../src/common.rs"]
mod common;
diff --git a/tests/d2s_test.rs b/tests/d2s_test.rs
index 604ab69..368cab6 100644
--- a/tests/d2s_test.rs
+++ b/tests/d2s_test.rs
@@ -18,6 +18,16 @@
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
+#![allow(
+ clippy::approx_constant,
+ clippy::cast_lossless,
+ clippy::float_cmp,
+ clippy::int_plus_one,
+ clippy::non_ascii_literal,
+ clippy::unreadable_literal,
+ clippy::unseparated_literal_suffix
+)]
+
#[macro_use]
mod macros;
diff --git a/tests/f2s_test.rs b/tests/f2s_test.rs
index 916250e..927fa7e 100644
--- a/tests/f2s_test.rs
+++ b/tests/f2s_test.rs
@@ -18,6 +18,14 @@
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
+#![allow(
+ clippy::approx_constant,
+ clippy::float_cmp,
+ clippy::non_ascii_literal,
+ clippy::unreadable_literal,
+ clippy::unseparated_literal_suffix
+)]
+
#[macro_use]
mod macros;
diff --git a/tests/s2d_test.rs b/tests/s2d_test.rs
index f51c1ed..7b42164 100644
--- a/tests/s2d_test.rs
+++ b/tests/s2d_test.rs
@@ -20,16 +20,35 @@
#![cfg(not(feature = "small"))]
#![allow(dead_code)]
+#![allow(
+ clippy::cast_lossless,
+ clippy::cast_possible_truncation,
+ clippy::cast_possible_wrap,
+ clippy::cast_sign_loss,
+ clippy::excessive_precision,
+ clippy::float_cmp,
+ clippy::manual_range_contains,
+ clippy::similar_names,
+ clippy::too_many_lines,
+ clippy::unreadable_literal,
+ clippy::unseparated_literal_suffix,
+ clippy::wildcard_imports
+)]
#[path = "../src/common.rs"]
mod common;
+#[cfg(not(feature = "small"))]
#[path = "../src/d2s_full_table.rs"]
mod d2s_full_table;
#[path = "../src/d2s_intrinsics.rs"]
mod d2s_intrinsics;
+#[cfg(feature = "small")]
+#[path = "../src/d2s_small_table.rs"]
+mod d2s_small_table;
+
#[path = "../src/d2s.rs"]
mod d2s;
@@ -77,6 +96,7 @@ fn test_basic() {
assert_eq!(1.0, s2d(b"1e0").unwrap());
assert_eq!(1.0, s2d(b"1E0").unwrap());
assert_eq!(1.0, s2d(b"000001.000000").unwrap());
+ assert_eq!(0.2316419, s2d(b"0.2316419").unwrap());
}
#[test]
@@ -128,3 +148,20 @@ fn test_issue157() {
s2d(b"1.2999999999999999E+154").unwrap(),
);
}
+
+#[test]
+fn test_issue173() {
+ // Denormal boundary
+ assert_eq!(
+ 2.2250738585072012e-308,
+ s2d(b"2.2250738585072012e-308").unwrap(),
+ );
+ assert_eq!(
+ 2.2250738585072013e-308,
+ s2d(b"2.2250738585072013e-308").unwrap(),
+ );
+ assert_eq!(
+ 2.2250738585072014e-308,
+ s2d(b"2.2250738585072014e-308").unwrap(),
+ );
+}
diff --git a/tests/s2f_test.rs b/tests/s2f_test.rs
index f49824a..5bae935 100644
--- a/tests/s2f_test.rs
+++ b/tests/s2f_test.rs
@@ -19,16 +19,36 @@
// KIND, either express or implied.
#![allow(dead_code)]
+#![allow(
+ clippy::cast_lossless,
+ clippy::cast_possible_truncation,
+ clippy::cast_possible_wrap,
+ clippy::cast_possible_wrap,
+ clippy::cast_sign_loss,
+ clippy::checked_conversions,
+ clippy::float_cmp,
+ clippy::manual_range_contains,
+ clippy::similar_names,
+ clippy::too_many_lines,
+ clippy::unreadable_literal,
+ clippy::unseparated_literal_suffix,
+ clippy::wildcard_imports
+)]
#[path = "../src/common.rs"]
mod common;
+#[cfg(not(feature = "small"))]
#[path = "../src/d2s_full_table.rs"]
mod d2s_full_table;
#[path = "../src/d2s_intrinsics.rs"]
mod d2s_intrinsics;
+#[cfg(feature = "small")]
+#[path = "../src/d2s_small_table.rs"]
+mod d2s_small_table;
+
#[path = "../src/d2s.rs"]
mod d2s;
@@ -74,4 +94,17 @@ fn test_min_max() {
fn test_mantissa_rounding_overflow() {
assert_eq!(1.0, s2f(b"0.999999999").unwrap());
assert_eq!(f32::INFINITY, s2f(b"3.4028236e+38").unwrap());
+ assert_eq!(1.1754944e-38, s2f(b"1.17549430e-38").unwrap()); // FLT_MIN
+ assert_eq!(1.1754944e-38, s2f(b"1.17549431e-38").unwrap());
+ assert_eq!(1.1754944e-38, s2f(b"1.17549432e-38").unwrap());
+ assert_eq!(1.1754944e-38, s2f(b"1.17549433e-38").unwrap());
+ assert_eq!(1.1754944e-38, s2f(b"1.17549434e-38").unwrap());
+ assert_eq!(1.1754944e-38, s2f(b"1.17549435e-38").unwrap());
+}
+
+#[test]
+fn test_trailing_zeros() {
+ assert_eq!(26843550.0, s2f(b"26843549.5").unwrap());
+ assert_eq!(50000004.0, s2f(b"50000002.5").unwrap());
+ assert_eq!(99999992.0, s2f(b"99999989.5").unwrap());
}