Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
Signed-off-by: zhongzc <zhongzc_arch@outlook.com>
  • Loading branch information
zhongzc committed Apr 18, 2020
1 parent 0346266 commit e37f8ac
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions components/tidb_query_datatype/src/codec/data_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl AsMySQLBool for Real {
impl AsMySQLBool for Bytes {
#[inline]
fn as_mysql_bool(&self, context: &mut EvalContext) -> Result<bool> {
Ok(!self.is_empty() && ConvertTo::<f64>::convert(self, context)? != 0.0)
Ok(!self.is_empty() && ConvertTo::<f64>::convert(self, context)? != 0f64)
}
}

Expand Down Expand Up @@ -140,7 +140,10 @@ mod tests {
(b"0x00", None),
(b"11.xx", None),
(b"xx.11", None),
(b".0000000000000000000000000000000000000000000000000000001", Some(true))
(
b".0000000000000000000000000000000000000000000000000000001",
Some(true),
),
];

let mut ctx = EvalContext::default();
Expand All @@ -164,11 +167,19 @@ mod tests {

// test overflow
let mut ctx = EvalContext::default();
let val: Result<bool> = f64::INFINITY.to_string().as_bytes().to_vec().as_mysql_bool(&mut ctx);
let val: Result<bool> = f64::INFINITY
.to_string()
.as_bytes()
.to_vec()
.as_mysql_bool(&mut ctx);
assert!(val.is_err());

let mut ctx = EvalContext::default();
let val: Result<bool> = f64::NEG_INFINITY.to_string().as_bytes().to_vec().as_mysql_bool(&mut ctx);
let val: Result<bool> = f64::NEG_INFINITY
.to_string()
.as_bytes()
.to_vec()
.as_mysql_bool(&mut ctx);
assert!(val.is_err());
}
}
}

0 comments on commit e37f8ac

Please sign in to comment.