@@ -53,46 +53,7 @@ test_round_trip!(f64_roundtrips, Double, f64, "double precision");
5353test_round_trip ! ( string_roundtrips, VarChar , String , "varchar" ) ;
5454test_round_trip ! ( text_roundtrips, Text , String , "text" ) ;
5555test_round_trip ! ( binary_roundtrips, Binary , Vec <u8 >, "bytea" ) ;
56-
57- macro_rules! test_newtype_round_trip {
58- ( $test_name: ident, $sql_type: ident, $newtype: ident, $tpe: ty, $sql_type_name: expr) => {
59- #[ test]
60- fn $test_name( ) {
61- fn round_trip( val: $tpe) -> bool {
62- test_type_round_trips:: <types:: $sql_type, _>( $newtype( val) , $sql_type_name)
63- }
64-
65- fn option_round_trip( val: Option <$tpe>) -> bool {
66- let val = val. map( $newtype) ;
67- test_type_round_trips:: <Nullable <types:: $sql_type>, _>( val, $sql_type_name)
68- }
69-
70- fn vec_round_trip( val: Vec <$tpe>) -> bool {
71- let val: Vec <_> = val. into_iter( ) . map( $newtype) . collect( ) ;
72- test_type_round_trips:: <Array <types:: $sql_type>, _>( val, concat!( $sql_type_name, "[]" ) )
73- }
74-
75- quickcheck( round_trip as fn ( $tpe) -> bool ) ;
76- quickcheck( option_round_trip as fn ( Option <$tpe>) -> bool ) ;
77- quickcheck( vec_round_trip as fn ( Vec <$tpe>) -> bool ) ;
78- }
79- }
80- }
81-
82- test_newtype_round_trip ! ( date_roundtrips, Date , PgDate , i32 , "date" ) ;
83- test_newtype_round_trip ! ( time_roundtrips, Time , to_pg_time, i64 , "time" ) ;
84- test_newtype_round_trip ! ( timestamp_roundtrips, Timestamp , PgTimestamp , i64 , "timestamp" ) ;
85- test_newtype_round_trip ! ( interval_roundtrips, Interval , to_pg_interval, ( i64 , i32 , i32 ) , "interval" ) ;
86-
87- fn to_pg_time ( int : i64 ) -> PgTime {
88- PgTime ( :: std:: cmp:: max ( 0 , int) )
89- }
90-
91- fn to_pg_interval ( vals : ( i64 , i32 , i32 ) ) -> PgInterval {
92- let ( microseconds, days, months) = vals;
93- PgInterval {
94- microseconds : microseconds,
95- days : days,
96- months : months,
97- }
98- }
56+ test_round_trip ! ( date_roundtrips, Date , PgDate , "date" ) ;
57+ test_round_trip ! ( time_roundtrips, Time , PgTime , "time" ) ;
58+ test_round_trip ! ( timestamp_roundtrips, Timestamp , PgTimestamp , "timestamp" ) ;
59+ test_round_trip ! ( interval_roundtrips, Interval , PgInterval , "interval" ) ;
0 commit comments