()
| 87 | |
| 88 | #[test] |
| 89 | fn test_get_beacon_start() { |
| 90 | let gps_epoch_time: DateTime<Utc> = Utc.with_ymd_and_hms(1980, 1, 6, 0, 0, 0).unwrap(); |
| 91 | |
| 92 | // For GPS epoch time |
| 93 | let start_ts = get_beacon_start(gps_epoch_time.to_gps_time()); |
| 94 | assert_eq!(start_ts, Duration::zero()); |
| 95 | |
| 96 | // For now |
| 97 | let start_ts = get_beacon_start(Utc::now().to_gps_time()); |
| 98 | |
| 99 | // > 0 |
| 100 | assert!(start_ts > Duration::zero()); |
| 101 | |
| 102 | // Multiple of 128 seconds. |
| 103 | assert_eq!( |
| 104 | 0, |
| 105 | start_ts.num_nanoseconds().unwrap() |
| 106 | % Duration::try_seconds(128) |
| 107 | .unwrap() |
| 108 | .num_nanoseconds() |
| 109 | .unwrap() |
| 110 | ); |
| 111 | |
| 112 | // Les than 128 seconds ago. |
| 113 | let ts = start_ts.to_date_time(); |
| 114 | assert!(ts < Utc::now()); |
| 115 | assert!((Utc::now() - ts) < *BEACON_PERIOD); |
| 116 | } |
| 117 | |
| 118 | #[test] |
| 119 | fn test_get_ping_offset() { |
nothing calls this directly
no test coverage detected