Update for upstream changes
This commit is contained in:
12
src/test.rs
12
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<T: Eq+FromSql+ToSql, S: Str>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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<S, T> {
|
||||
type_: BoundType
|
||||
}
|
||||
|
||||
impl<S: BoundSided, T: fmt::Show> fmt::Show for RangeBound<S, T> {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
let chars = match self.type_ {
|
||||
Inclusive => ['[', ']'],
|
||||
Exclusive => ['(', ')'],
|
||||
};
|
||||
|
||||
match BoundSided::side(None::<S>) {
|
||||
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<S: BoundSided, T: Ord> Ord for RangeBound<S, T> {
|
||||
fn lt(&self, other: &RangeBound<S, T>) -> bool {
|
||||
match (BoundSided::side(None::<S>), self.type_, other.type_) {
|
||||
@@ -227,6 +248,25 @@ pub enum Range<T> {
|
||||
Option<RangeBound<UpperBound, T>>)
|
||||
}
|
||||
|
||||
impl<T: fmt::Show> fmt::Show for Range<T> {
|
||||
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<T: Ord+Normalizable> Range<T> {
|
||||
/// Creates a new range.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user