rust-postgres/tests/types/time.rs

22 lines
748 B
Rust
Raw Normal View History

2014-11-18 03:11:32 +00:00
extern crate time;
use self::time::Timespec;
use types::test_type;
#[test]
fn test_tm_params() {
fn make_check<'a>(time: &'a str) -> (Option<Timespec>, &'a str) {
(Some(time::strptime(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap().to_timespec()), time)
}
test_type("TIMESTAMP",
&[make_check("'1970-01-01 00:00:00.01'"),
2014-11-18 03:11:32 +00:00
make_check("'1965-09-25 11:19:33.100314'"),
make_check("'2010-02-09 23:11:45.1202'"),
(None, "NULL")]);
test_type("TIMESTAMP WITH TIME ZONE",
&[make_check("'1970-01-01 00:00:00.01'"),
2014-11-18 03:11:32 +00:00
make_check("'1965-09-25 11:19:33.100314'"),
make_check("'2010-02-09 23:11:45.1202'"),
(None, "NULL")]);
}