Fix tests

This commit is contained in:
Steven Fackler
2019-10-12 17:47:47 -07:00
parent ffd7245e54
commit 0736382593
9 changed files with 30 additions and 21 deletions

View File

@@ -1,3 +1,4 @@
use bytes::BytesMut;
use fallible_iterator::FallibleIterator;
use std::collections::HashMap;
@@ -6,32 +7,32 @@ use crate::IsNull;
#[test]
fn bool() {
let mut buf = vec![];
let mut buf = BytesMut::new();
bool_to_sql(true, &mut buf);
assert_eq!(bool_from_sql(&buf).unwrap(), true);
let mut buf = vec![];
let mut buf = BytesMut::new();
bool_to_sql(false, &mut buf);
assert_eq!(bool_from_sql(&buf).unwrap(), false);
}
#[test]
fn int2() {
let mut buf = vec![];
let mut buf = BytesMut::new();
int2_to_sql(0x0102, &mut buf);
assert_eq!(int2_from_sql(&buf).unwrap(), 0x0102);
}
#[test]
fn int4() {
let mut buf = vec![];
let mut buf = BytesMut::new();
int4_to_sql(0x0102_0304, &mut buf);
assert_eq!(int4_from_sql(&buf).unwrap(), 0x0102_0304);
}
#[test]
fn int8() {
let mut buf = vec![];
let mut buf = BytesMut::new();
int8_to_sql(0x0102_0304_0506_0708, &mut buf);
assert_eq!(int8_from_sql(&buf).unwrap(), 0x0102_0304_0506_0708);
}
@@ -39,7 +40,7 @@ fn int8() {
#[test]
#[allow(clippy::float_cmp)]
fn float4() {
let mut buf = vec![];
let mut buf = BytesMut::new();
float4_to_sql(10343.95, &mut buf);
assert_eq!(float4_from_sql(&buf).unwrap(), 10343.95);
}
@@ -47,7 +48,7 @@ fn float4() {
#[test]
#[allow(clippy::float_cmp)]
fn float8() {
let mut buf = vec![];
let mut buf = BytesMut::new();
float8_to_sql(10343.95, &mut buf);
assert_eq!(float8_from_sql(&buf).unwrap(), 10343.95);
}
@@ -58,7 +59,7 @@ fn hstore() {
map.insert("hello", Some("world"));
map.insert("hola", None);
let mut buf = vec![];
let mut buf = BytesMut::new();
hstore_to_sql(map.iter().map(|(&k, &v)| (k, v)), &mut buf).unwrap();
assert_eq!(
hstore_from_sql(&buf)
@@ -74,7 +75,7 @@ fn varbit() {
let len = 12;
let bits = [0b0010_1011, 0b0000_1111];
let mut buf = vec![];
let mut buf = BytesMut::new();
varbit_to_sql(len, bits.iter().cloned(), &mut buf).unwrap();
let out = varbit_from_sql(&buf).unwrap();
assert_eq!(out.len(), len);
@@ -95,7 +96,7 @@ fn array() {
];
let values = [None, Some(&b"hello"[..])];
let mut buf = vec![];
let mut buf = BytesMut::new();
array_to_sql(
dimensions.iter().cloned(),
10,
@@ -132,7 +133,7 @@ fn non_null_array() {
];
let values = [Some(&b"hola"[..]), Some(&b"hello"[..])];
let mut buf = vec![];
let mut buf = BytesMut::new();
array_to_sql(
dimensions.iter().cloned(),
10,