fix(typedef): resolve pre-existing clippy warnings in test code
- sequential_reader.rs: change test helper write_u32/write_string param from &mut Vec<u8> to &mut [u8] (clippy::ptr_arg) - validation.rs: replace 3.14/2.71 with 3.5/2.5 in test instances to avoid clippy::approx_constant (f32::consts::PI approximation)
This commit is contained in:
1 parent
937df02f85
commit
bf868157d3
2 files changed
+4
-4
No files matched your search
@@ -852,7 +852,7 @@ mod tests {
|
||||
const LE: Endian = Endian::Little;
|
||||
const BE: Endian = Endian::Big;
|
||||
|
||||
fn write_u32(buf: &mut Vec<u8>, offset: usize, value: u32, endian: Endian) {
|
||||
fn write_u32(buf: &mut [u8], offset: usize, value: u32, endian: Endian) {
|
||||
let bytes = match endian {
|
||||
Endian::Little => value.to_le_bytes(),
|
||||
Endian::Big => value.to_be_bytes(),
|
||||
@@ -860,7 +860,7 @@ mod tests {
|
||||
buf[offset..offset + 4].copy_from_slice(&bytes);
|
||||
}
|
||||
|
||||
fn write_string(buf: &mut Vec<u8>, offset: usize, value: &str, endian: Endian) -> usize {
|
||||
fn write_string(buf: &mut [u8], offset: usize, value: &str, endian: Endian) -> usize {
|
||||
let bytes = value.as_bytes();
|
||||
let total = 4 + bytes.len();
|
||||
write_u32(buf, offset, bytes.len() as u32, endian);
|
||||
|
||||
@@ -605,7 +605,7 @@ mod tests {
|
||||
let validator = validator_for(&schema);
|
||||
let instance = json!({
|
||||
"id": 42,
|
||||
"score": 3.14,
|
||||
"score": 3.5,
|
||||
"flag": 1,
|
||||
"count": 1000
|
||||
});
|
||||
@@ -688,7 +688,7 @@ mod tests {
|
||||
"required": ["f32", "f64"]
|
||||
});
|
||||
let validator = validator_for(&schema);
|
||||
assert!(validator.is_valid(&json!({"f32": 3.14, "f64": 2.71})));
|
||||
assert!(validator.is_valid(&json!({"f32": 3.5, "f64": 2.5})));
|
||||
assert!(validator.is_valid(&json!({"f32": 0, "f64": 0})));
|
||||
assert!(!validator.is_valid(&json!({"f32": "x", "f64": 0})));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user