From 10065bda35f3ccd9d9a88848742b9b322a7bf05c Mon Sep 17 00:00:00 2001 From: Lauri Virtanen Date: Sun, 29 Dec 2024 19:03:47 +0200 Subject: [PATCH] Don't use inaccurate pi values, make clippy happy --- core/types.rs | 9 +++++---- core/vdbe/mod.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/types.rs b/core/types.rs index fc0f5301a..7b5814397 100644 --- a/core/types.rs +++ b/core/types.rs @@ -647,7 +647,8 @@ mod tests { #[test] fn test_serialize_float() { - let record = OwnedRecord::new(vec![OwnedValue::Float(3.14159)]); + #[warn(clippy::approx_constant)] + let record = OwnedRecord::new(vec![OwnedValue::Float(3.15555)]); let mut buf = Vec::new(); record.serialize(&mut buf); @@ -660,7 +661,7 @@ mod tests { // Check that the bytes after the header can be interpreted as the float let float_bytes = &buf[header_length..header_length + size_of::()]; let float = f64::from_be_bytes(float_bytes.try_into().unwrap()); - assert_eq!(float, 3.14159); + assert_eq!(float, 3.15555); // Check that buffer length is correct assert_eq!(buf.len(), header_length + size_of::()); } @@ -709,7 +710,7 @@ mod tests { let record = OwnedRecord::new(vec![ OwnedValue::Null, OwnedValue::Integer(42), - OwnedValue::Float(3.14), + OwnedValue::Float(3.15), OwnedValue::Text(LimboText::new(text.clone())), ]); let mut buf = Vec::new(); @@ -741,7 +742,7 @@ mod tests { let val_text = String::from_utf8(text_bytes.to_vec()).unwrap(); assert_eq!(val_int8, 42); - assert_eq!(val_float, 3.14); + assert_eq!(val_float, 3.15); assert_eq!(val_text, "test"); // Check that buffer length is correct diff --git a/core/vdbe/mod.rs b/core/vdbe/mod.rs index 8a8c60c97..609b8ad86 100644 --- a/core/vdbe/mod.rs +++ b/core/vdbe/mod.rs @@ -4097,7 +4097,7 @@ mod tests { expected_len: 2, }, TestCase { - input: OwnedValue::Float(-3.14), + input: OwnedValue::Float(-3.15), expected_len: 1, }, TestCase {