fix: test

This commit is contained in:
xiaopengli89 2020-04-06 19:04:34 +08:00 committed by Ryan Leckey
parent 771d423c6f
commit 229635771a

View File

@ -151,24 +151,24 @@ impl Decode<'_, MySql> for BigDecimal {
fn test_encode_decimal() {
let v = BigDecimal::new(BigInt::from(-105), 2);
let mut buf: Vec<u8> = vec![];
v.encode(&mut buf);
<BigDecimal as Encode<MySql>>::encode(&v, &mut buf);
assert_eq!(buf, vec![0x05, 0x2D, 0x31, 0x2E, 0x30, 0x35]);
let v = BigDecimal::new(BigInt::from(-105), -3);
let mut buf: Vec<u8> = vec![];
v.encode(&mut buf);
<BigDecimal as Encode<MySql>>::encode(&v, &mut buf);
assert_eq!(buf, vec![0x07, 0x2D, 0x31, 0x30, 0x35, 0x30, 0x30, 0x30]);
let v = BigDecimal::new(BigInt::from(105), 5);
let mut buf: Vec<u8> = vec![];
v.encode(&mut buf);
<BigDecimal as Encode<MySql>>::encode(&v, &mut buf);
assert_eq!(buf, vec![0x07, 0x30, 0x2E, 0x30, 0x30, 0x31, 0x30, 0x35]);
}
#[test]
fn test_decode_decimal() {
let buf: Vec<u8> = vec![0x05, 0x2D, 0x31, 0x2E, 0x30, 0x35];
let v = BigDecimal::decode(MySqlValue::binary(
let v = <BigDecimal as Decode<'_, MySql>>::decode(MySqlValue::binary(
MySqlTypeInfo::new(TypeId::NEWDECIMAL),
buf.as_slice(),
))
@ -176,7 +176,7 @@ fn test_decode_decimal() {
assert_eq!(v.to_string(), "-1.05");
let buf: Vec<u8> = vec![0x04, 0x30, 0x2E, 0x30, 0x35];
let v = BigDecimal::decode(MySqlValue::binary(
let v = <BigDecimal as Decode<'_, MySql>>::decode(MySqlValue::binary(
MySqlTypeInfo::new(TypeId::NEWDECIMAL),
buf.as_slice(),
))
@ -184,7 +184,7 @@ fn test_decode_decimal() {
assert_eq!(v.to_string(), "0.05");
let buf: Vec<u8> = vec![0x06, 0x2D, 0x39, 0x30, 0x30, 0x30, 0x30];
let v = BigDecimal::decode(MySqlValue::binary(
let v = <BigDecimal as Decode<'_, MySql>>::decode(MySqlValue::binary(
MySqlTypeInfo::new(TypeId::NEWDECIMAL),
buf.as_slice(),
))