From e2d305033e1d7796fc99bea211955ba99d3448ad Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 23 Sep 2019 15:57:58 -0700 Subject: [PATCH] Remove vec workaround in tests --- tokio-postgres/tests/test/types/bit_vec_07.rs | 4 +- tokio-postgres/tests/test/types/chrono_04.rs | 14 +++---- tokio-postgres/tests/test/types/eui48_04.rs | 2 +- tokio-postgres/tests/test/types/geo_010.rs | 6 +-- tokio-postgres/tests/test/types/mod.rs | 38 +++++++++---------- .../tests/test/types/serde_json_1.rs | 4 +- tokio-postgres/tests/test/types/uuid_07.rs | 2 +- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/tokio-postgres/tests/test/types/bit_vec_07.rs b/tokio-postgres/tests/test/types/bit_vec_07.rs index 4c0e426f..5ea4a00b 100644 --- a/tokio-postgres/tests/test/types/bit_vec_07.rs +++ b/tokio-postgres/tests/test/types/bit_vec_07.rs @@ -9,7 +9,7 @@ async fn test_bit_params() { bv.pop(); test_type( "BIT(14)", - vec![(Some(bv), "B'01101001000001'"), (None, "NULL")], + &[(Some(bv), "B'01101001000001'"), (None, "NULL")], ) .await } @@ -21,7 +21,7 @@ async fn test_varbit_params() { bv.pop(); test_type( "VARBIT", - vec![ + &[ (Some(bv), "B'01101001000001'"), (Some(BitVec::from_bytes(&[])), "B''"), (None, "NULL"), diff --git a/tokio-postgres/tests/test/types/chrono_04.rs b/tokio-postgres/tests/test/types/chrono_04.rs index a48346bc..13c8dc14 100644 --- a/tokio-postgres/tests/test/types/chrono_04.rs +++ b/tokio-postgres/tests/test/types/chrono_04.rs @@ -13,7 +13,7 @@ async fn test_naive_date_time_params() { } test_type( "TIMESTAMP", - vec![ + &[ make_check("'1970-01-01 00:00:00.010000000'"), make_check("'1965-09-25 11:19:33.100314000'"), make_check("'2010-02-09 23:11:45.120200000'"), @@ -35,7 +35,7 @@ async fn test_with_special_naive_date_time_params() { } test_type( "TIMESTAMP", - vec![ + &[ make_check("'1970-01-01 00:00:00.010000000'"), make_check("'1965-09-25 11:19:33.100314000'"), make_check("'2010-02-09 23:11:45.120200000'"), @@ -59,7 +59,7 @@ async fn test_date_time_params() { } test_type( "TIMESTAMP WITH TIME ZONE", - vec![ + &[ make_check("'1970-01-01 00:00:00.010000000'"), make_check("'1965-09-25 11:19:33.100314000'"), make_check("'2010-02-09 23:11:45.120200000'"), @@ -82,7 +82,7 @@ async fn test_with_special_date_time_params() { } test_type( "TIMESTAMP WITH TIME ZONE", - vec![ + &[ make_check("'1970-01-01 00:00:00.010000000'"), make_check("'1965-09-25 11:19:33.100314000'"), make_check("'2010-02-09 23:11:45.120200000'"), @@ -103,7 +103,7 @@ async fn test_date_params() { } test_type( "DATE", - vec![ + &[ make_check("'1970-01-01'"), make_check("'1965-09-25'"), make_check("'2010-02-09'"), @@ -123,7 +123,7 @@ async fn test_with_special_date_params() { } test_type( "DATE", - vec![ + &[ make_check("'1970-01-01'"), make_check("'1965-09-25'"), make_check("'2010-02-09'"), @@ -144,7 +144,7 @@ async fn test_time_params() { } test_type( "TIME", - vec![ + &[ make_check("'00:00:00.010000000'"), make_check("'11:19:33.100314000'"), make_check("'23:11:45.120200000'"), diff --git a/tokio-postgres/tests/test/types/eui48_04.rs b/tokio-postgres/tests/test/types/eui48_04.rs index 0cfb7cb5..074faa37 100644 --- a/tokio-postgres/tests/test/types/eui48_04.rs +++ b/tokio-postgres/tests/test/types/eui48_04.rs @@ -6,7 +6,7 @@ use crate::types::test_type; async fn test_eui48_params() { test_type( "MACADDR", - vec![ + &[ ( Some(MacAddress::parse_str("12-34-56-AB-CD-EF").unwrap()), "'12-34-56-ab-cd-ef'", diff --git a/tokio-postgres/tests/test/types/geo_010.rs b/tokio-postgres/tests/test/types/geo_010.rs index ecb1cbfc..6e3d835b 100644 --- a/tokio-postgres/tests/test/types/geo_010.rs +++ b/tokio-postgres/tests/test/types/geo_010.rs @@ -6,7 +6,7 @@ use crate::types::test_type; async fn test_point_params() { test_type( "POINT", - vec![ + &[ (Some(Point::new(0.0, 0.0)), "POINT(0, 0)"), (Some(Point::new(-3.14, 1.618)), "POINT(-3.14, 1.618)"), (None, "NULL"), @@ -19,7 +19,7 @@ async fn test_point_params() { async fn test_box_params() { test_type( "BOX", - vec![ + &[ ( Some(Rect { min: Coordinate { x: -3.14, y: 1.618 }, @@ -48,7 +48,7 @@ async fn test_path_params() { ]; test_type( "PATH", - vec![ + &[ ( Some(LineString(points)), "path '((0, 0), (-3.14, 1.618), (160.0, 69701.5615))'", diff --git a/tokio-postgres/tests/test/types/mod.rs b/tokio-postgres/tests/test/types/mod.rs index 46d45144..89cce955 100644 --- a/tokio-postgres/tests/test/types/mod.rs +++ b/tokio-postgres/tests/test/types/mod.rs @@ -25,7 +25,7 @@ mod serde_json_1; #[cfg(feature = "with-uuid-0_7")] mod uuid_07; -async fn test_type(sql_type: &str, checks: Vec<(T, S)>) +async fn test_type(sql_type: &str, checks: &[(T, S)]) where T: PartialEq + for<'a> FromSqlOwned + ToSql, S: fmt::Display, @@ -43,7 +43,7 @@ where .await .unwrap(); let result = rows[0].get(0); - assert_eq!(val, result); + assert_eq!(val, &result); let stmt = client .prepare(&format!("SELECT $1::{}", sql_type)) @@ -55,7 +55,7 @@ where .await .unwrap(); let result = rows[0].get(0); - assert_eq!(val, result); + assert_eq!(val, &result); } } @@ -63,21 +63,21 @@ where async fn test_bool_params() { test_type( "BOOL", - vec![(Some(true), "'t'"), (Some(false), "'f'"), (None, "NULL")], + &[(Some(true), "'t'"), (Some(false), "'f'"), (None, "NULL")], ) .await; } #[tokio::test] async fn test_i8_params() { - test_type("\"char\"", vec![(Some('a' as i8), "'a'"), (None, "NULL")]).await; + test_type("\"char\"", &[(Some('a' as i8), "'a'"), (None, "NULL")]).await; } #[tokio::test] async fn test_name_params() { test_type( "NAME", - vec![ + &[ (Some("hello world".to_owned()), "'hello world'"), ( Some("イロハニホヘト チリヌルヲ".to_owned()), @@ -93,7 +93,7 @@ async fn test_name_params() { async fn test_i16_params() { test_type( "SMALLINT", - vec![ + &[ (Some(15001i16), "15001"), (Some(-15001i16), "-15001"), (None, "NULL"), @@ -106,7 +106,7 @@ async fn test_i16_params() { async fn test_i32_params() { test_type( "INT", - vec![ + &[ (Some(2_147_483_548i32), "2147483548"), (Some(-2_147_483_548i32), "-2147483548"), (None, "NULL"), @@ -119,7 +119,7 @@ async fn test_i32_params() { async fn test_oid_params() { test_type( "OID", - vec![ + &[ (Some(2_147_483_548u32), "2147483548"), (Some(4_000_000_000), "4000000000"), (None, "NULL"), @@ -132,7 +132,7 @@ async fn test_oid_params() { async fn test_i64_params() { test_type( "BIGINT", - vec![ + &[ (Some(9_223_372_036_854_775_708i64), "9223372036854775708"), (Some(-9_223_372_036_854_775_708i64), "-9223372036854775708"), (None, "NULL"), @@ -145,7 +145,7 @@ async fn test_i64_params() { async fn test_f32_params() { test_type( "REAL", - vec![ + &[ (Some(f32::INFINITY), "'infinity'"), (Some(f32::NEG_INFINITY), "'-infinity'"), (Some(1000.55), "1000.55"), @@ -159,7 +159,7 @@ async fn test_f32_params() { async fn test_f64_params() { test_type( "DOUBLE PRECISION", - vec![ + &[ (Some(f64::INFINITY), "'infinity'"), (Some(f64::NEG_INFINITY), "'-infinity'"), (Some(10000.55), "10000.55"), @@ -173,7 +173,7 @@ async fn test_f64_params() { async fn test_varchar_params() { test_type( "VARCHAR", - vec![ + &[ (Some("hello world".to_owned()), "'hello world'"), ( Some("イロハニホヘト チリヌルヲ".to_owned()), @@ -189,7 +189,7 @@ async fn test_varchar_params() { async fn test_text_params() { test_type( "TEXT", - vec![ + &[ (Some("hello world".to_owned()), "'hello world'"), ( Some("イロハニホヘト チリヌルヲ".to_owned()), @@ -296,7 +296,7 @@ async fn test_citext_params() { async fn test_bytea_params() { test_type( "BYTEA", - vec![ + &[ (Some(vec![0u8, 1, 2, 3, 254, 255]), "'\\x00010203feff'"), (None, "NULL"), ], @@ -329,7 +329,7 @@ macro_rules! make_map { async fn test_hstore_params() { test_type( "hstore", - vec![ + &[ ( Some(make_map!("a".to_owned() => Some("1".to_owned()))), "'a=>1'", @@ -350,7 +350,7 @@ async fn test_hstore_params() { async fn test_array_params() { test_type( "integer[]", - vec![ + &[ (Some(vec![1i32, 2i32]), "ARRAY[1,2]"), (Some(vec![1i32]), "ARRAY[1]"), (Some(vec![]), "ARRAY[]"), @@ -607,7 +607,7 @@ async fn enum_() { async fn system_time() { test_type( "TIMESTAMP", - vec![ + &[ ( Some(UNIX_EPOCH + Duration::from_millis(1_010)), "'1970-01-01 00:00:01.01'", @@ -630,7 +630,7 @@ async fn system_time() { async fn inet() { test_type( "INET", - vec![ + &[ (Some("127.0.0.1".parse::().unwrap()), "'127.0.0.1'"), ( Some("127.0.0.1".parse::().unwrap()), diff --git a/tokio-postgres/tests/test/types/serde_json_1.rs b/tokio-postgres/tests/test/types/serde_json_1.rs index f48c188f..93ec61d7 100644 --- a/tokio-postgres/tests/test/types/serde_json_1.rs +++ b/tokio-postgres/tests/test/types/serde_json_1.rs @@ -6,7 +6,7 @@ use crate::types::test_type; async fn test_json_params() { test_type( "JSON", - vec![ + &[ ( Some(serde_json_1::from_str::("[10, 11, 12]").unwrap()), "'[10, 11, 12]'", @@ -25,7 +25,7 @@ async fn test_json_params() { async fn test_jsonb_params() { test_type( "JSONB", - vec![ + &[ ( Some(serde_json_1::from_str::("[10, 11, 12]").unwrap()), "'[10, 11, 12]'", diff --git a/tokio-postgres/tests/test/types/uuid_07.rs b/tokio-postgres/tests/test/types/uuid_07.rs index 8e60fe3a..563cfa4c 100644 --- a/tokio-postgres/tests/test/types/uuid_07.rs +++ b/tokio-postgres/tests/test/types/uuid_07.rs @@ -6,7 +6,7 @@ use crate::types::test_type; async fn test_uuid_params() { test_type( "UUID", - vec![ + &[ ( Some(Uuid::parse_str("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11").unwrap()), "'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'",