extern crate time_humanize;
#[cfg(test)]
mod duration {
use time_humanize::HumanTime;
#[test]
fn now() {
let english = HumanTime::from(0);
assert_eq!("now", format!("{}", english));
}
#[test]
fn plus_5s() {
let english = HumanTime::from(5);
assert_eq!("now", format!("{}", english));
}
#[test]
fn minus_5s() {
let english = HumanTime::from(-5);
assert_eq!("now", format!("{}", english));
}
#[test]
fn plus_15s() {
let english = HumanTime::from(15);
assert_eq!("in 15 seconds", format!("{}", english));
}
#[test]
fn minus_15s() {
let english = HumanTime::from(-15);
assert_eq!("15 seconds ago", format!("{}", english));
}
#[test]
fn plus_95s() {
let english = HumanTime::from(95);
assert_eq!("in 2 minutes", format!("{}", english));
}
#[test]
fn minus_95s() {
let english = HumanTime::from(-95);
assert_eq!("2 minutes ago", format!("{}", english));
}
#[test]
fn plus_125s() {
let english = HumanTime::from(125);
assert_eq!("in 2 minutes", format!("{}", english));
}
#[test]
fn minus_125s() {
let english = HumanTime::from(-125);
assert_eq!("2 minutes ago", format!("{}", english));
}
#[test]
fn plus_31m() {
let english = HumanTime::from_minutes(31);
assert_eq!("in 31 minutes", format!("{}", english));
}
#[test]
fn minus_31m() {
let english = HumanTime::from(60 * -31);
assert_eq!("31 minutes ago", format!("{}", english));
}
#[test]
fn plus_45m() {
let english = HumanTime::from(60 * 45);
assert_eq!("in 45 minutes", format!("{}", english));
}
#[test]
fn minus_45m() {
let english = HumanTime::from(60 * -45);
assert_eq!("45 minutes ago", format!("{}", english));
}
#[test]
fn plus_46m() {
let english = HumanTime::from(60 * 46);
assert_eq!("in an hour", format!("{}", english));
}
#[test]
fn minus_46m() {
let english = HumanTime::from(60 * -46);
assert_eq!("an hour ago", format!("{}", english));
}
#[test]
fn plus_1h() {
let english = HumanTime::from(60 * 60);
assert_eq!("in an hour", format!("{}", english));
}
#[test]
fn minus_1h() {
let english = HumanTime::from(-60 * 60);
assert_eq!("an hour ago", format!("{}", english));
}
#[test]
fn plus_12h() {
let english = HumanTime::from(60 * 60 * 12);
assert_eq!("in 12 hours", format!("{}", english));
}
#[test]
fn minus_12h() {
let english = HumanTime::from(60 * 60 * -12);
assert_eq!("12 hours ago", format!("{}", english));
}
#[test]
fn plus_23h() {
let english = HumanTime::from(60 * 60 * 23);
assert_eq!("in a day", format!("{}", english));
}
#[test]
fn minus_23h() {
let english = HumanTime::from(60 * 60 * -23);
assert_eq!("a day ago", format!("{}", english));
}
#[test]
fn plus_26h() {
let english = HumanTime::from(60 * 60 * 26);
assert_eq!("in a day", format!("{}", english));
}
#[test]
fn minus_26h() {
let english = HumanTime::from(60 * 60 * -26);
assert_eq!("a day ago", format!("{}", english));
}
#[test]
fn plus_1d() {
let english = HumanTime::from(24 * 60 * 60);
assert_eq!("in a day", format!("{}", english));
}
#[test]
fn minus_1d() {
let english = HumanTime::from(-24 * 60 * 60);
assert_eq!("a day ago", format!("{}", english));
}
#[test]
fn plus_2d() {
let english = HumanTime::from(24 * 60 * 60 * 2);
assert_eq!("in 2 days", format!("{}", english));
}
#[test]
fn minus_2d() {
let english = HumanTime::from(24 * 60 * 60 * -2);
assert_eq!("2 days ago", format!("{}", english));
}
}