Commit fb3b8b84 authored by daniel.eades's avatar daniel.eades
Browse files

fix/silence clippy lints in test modules

parent 9cf1fa36
......@@ -349,6 +349,7 @@ impl Writeable for SocksAddr {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use hex_literal::hex;
......@@ -404,7 +405,7 @@ mod test {
fn socks5_init_noauth() {
let mut h = SocksHandshake::new();
let a = h.handshake(&hex!("05 01 00")[..]).unwrap();
assert_eq!(a.finished, false);
assert!(!a.finished);
assert_eq!(a.drain, 3);
assert_eq!(a.reply, &[5, 0]);
assert_eq!(h.state, State::Socks5Wait);
......@@ -414,7 +415,7 @@ mod test {
fn socks5_init_username() {
let mut h = SocksHandshake::new();
let a = h.handshake(&hex!("05 04 00023031")[..]).unwrap();
assert_eq!(a.finished, false);
assert!(!a.finished);
assert_eq!(a.drain, 6);
assert_eq!(a.reply, &[5, 2]);
assert_eq!(h.state, State::Socks5Username);
......
......@@ -254,6 +254,7 @@ impl fmt::Display for SocksAddr {
#[cfg(test)]
mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use std::convert::TryInto;
......
......@@ -16,6 +16,9 @@ categories = [ "rust-patterns" ]
derive_more = "0.99.0"
thiserror = "1.0.24"
[dev-dependencies]
float-cmp = "0.9.0"
# [derive_more]
# default-features = false
# features = ["from"]
\ No newline at end of file
......@@ -335,6 +335,9 @@ impl SendMeVersion {
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use float_cmp::assert_approx_eq;
use super::*;
use std::convert::TryInto;
......@@ -431,7 +434,7 @@ mod tests {
fn bounded_to_f64() {
let x: BoundedInt32<-100, 100> = BoundedInt32::checked_new(77).unwrap();
let f: f64 = x.into();
assert_eq!(f, 77.0);
assert_approx_eq!(f64, f, 77.0);
}
#[test]
......@@ -453,8 +456,8 @@ mod tests {
let f: bool = zero.into();
let t: bool = one.into();
assert_eq!(f, false);
assert_eq!(t, true);
assert!(!f);
assert!(t);
}
#[test]
......@@ -480,15 +483,15 @@ mod tests {
type Pct = Percentage<u8>;
let p = Pct::new(100);
assert_eq!(p.as_percent(), 100);
assert_eq!(p.as_fraction(), 1.0);
assert_approx_eq!(f64, p.as_fraction(), 1.0);
let p = Pct::new(0);
assert_eq!(p.as_percent(), 0);
assert_eq!(p.as_fraction(), 0.0);
assert_approx_eq!(f64, p.as_fraction(), 0.0);
let p = Pct::new(25);
assert_eq!(p.as_percent(), 25);
assert_eq!(p.as_fraction(), 0.25);
assert_approx_eq!(f64, p.as_fraction(), 0.25);
}
#[test]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment