diff --git a/src/test.rs b/src/test.rs index f757d2b7..7961361c 100644 --- a/src/test.rs +++ b/src/test.rs @@ -314,16 +314,16 @@ fn test_lazy_query() { fn test_param_types() { let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl); let stmt = conn.prepare("SELECT $1::INT, $2::VARCHAR"); - assert_eq!(stmt.param_types(), [PgInt4, PgVarchar]); + assert_eq!(stmt.param_types(), &[PgInt4, PgVarchar]); } #[test] fn test_result_descriptions() { let conn = PostgresConnection::connect("postgres://postgres@localhost", &NoSsl); let stmt = conn.prepare("SELECT 1::INT as a, 'hi'::VARCHAR as b"); - assert_eq!(stmt.result_descriptions(), - [ResultDescription { name: ~"a", ty: PgInt4}, - ResultDescription { name: ~"b", ty: PgVarchar}]); + assert!(stmt.result_descriptions() == + [ResultDescription { name: ~"a", ty: PgInt4}, + ResultDescription { name: ~"b", ty: PgVarchar}]); } #[test] @@ -344,11 +344,11 @@ fn test_type(sql_type: &str, checks: &[(T, S)]) { for &(ref val, ref repr) in checks.iter() { let stmt = conn.prepare(format!("SELECT {:s}::{}", *repr, sql_type)); let result = stmt.query([]).next().unwrap()[1]; - assert_eq!(val, &result); + assert!(val == &result); let stmt = conn.prepare("SELECT $1::" + sql_type); let result = stmt.query([val as &ToSql]).next().unwrap()[1]; - assert_eq!(val, &result); + assert!(val == &result); } } diff --git a/src/types/array.rs b/src/types/array.rs index 3c24bb0e..51fbd2ea 100644 --- a/src/types/array.rs +++ b/src/types/array.rs @@ -4,7 +4,7 @@ use std::cast; use std::vec; /// Information about a dimension of an array -#[deriving(Eq, Clone)] +#[deriving(Eq, Clone, Show)] pub struct DimensionInfo { /// The size of the dimension len: uint, @@ -253,8 +253,8 @@ mod tests { #[test] fn test_from_vec() { let a = ArrayBase::from_vec(~[0, 1, 2], -1); - assert_eq!([DimensionInfo { len: 3, lower_bound: -1 }], - a.dimension_info()); + assert!([DimensionInfo { len: 3, lower_bound: -1 }] == + a.dimension_info()); assert_eq!(&0, a.get(-1)); assert_eq!(&1, a.get(0)); assert_eq!(&2, a.get(1)); diff --git a/src/types/range.rs b/src/types/range.rs index b7c86327..35f430d5 100644 --- a/src/types/range.rs +++ b/src/types/range.rs @@ -4,6 +4,7 @@ extern crate extra; use std::cmp; +use std::fmt; use std::i32; use std::i64; use time::Timespec; @@ -179,6 +180,26 @@ pub struct RangeBound { type_: BoundType } +impl fmt::Show for RangeBound { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let chars = match self.type_ { + Inclusive => ['[', ']'], + Exclusive => ['(', ')'], + }; + + match BoundSided::side(None::) { + Lower => { + try!(formatter.buf.write_char(chars[0])); + self.value.fmt(formatter) + } + Upper => { + try!(self.value.fmt(formatter)); + formatter.buf.write_char(chars[1]) + } + } + } +} + impl Ord for RangeBound { fn lt(&self, other: &RangeBound) -> bool { match (BoundSided::side(None::), self.type_, other.type_) { @@ -227,6 +248,25 @@ pub enum Range { Option>) } +impl fmt::Show for Range { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + match *self { + Empty => formatter.buf.write_str("empty"), + Normal(ref lower, ref upper) => { + match *lower { + Some(ref bound) => try!(bound.fmt(formatter)), + None => try!(formatter.buf.write_char('(')), + } + try!(formatter.buf.write_char(',')); + match *upper { + Some(ref bound) => bound.fmt(formatter), + None => formatter.buf.write_char(')'), + } + } + } + } +} + impl Range { /// Creates a new range. ///