Browse Source

add test to verify Utc -> nanos is lossless

master
Jonathan Strong 5 years ago
parent
commit
7d2fce56a4
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      src/lib.rs

+ 18
- 0
src/lib.rs View File

@@ -118,3 +118,21 @@ pub fn short_uuid(id: &Uuid) -> String {
format!("{}", &id.to_string()[..8])
}
}

#[allow(unused)]
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn utc_nanos_round_trip() {
let utc = Utc::now();
let ns = inanos(utc);
let rt = nanos_utc(ns);
assert_eq!(utc, rt);
let utc = Utc.ymd(1970, 1, 1).and_hms(0, 0, 0);
let ns = inanos(utc);
let rt = nanos_utc(ns);
assert_eq!(utc, rt);
}
}

Loading…
Cancel
Save