Skip to content

Commit

Permalink
Increase Duration approximate equal threshold to 1us
Browse files Browse the repository at this point in the history
Previously this threshold when testing was 100ns, but the Windows
documentation states:

> which is a high resolution (<1us) time stamp

which presumably means that we could have up to 1us resolution, which
means that 100ns doesn't capture "equivalent" time intervals due to
various bits of rounding here and there.

It's hoped that this..

Closes rust-lang#56034
  • Loading branch information
alexcrichton authored and pietroalbini committed Nov 19, 2018
1 parent 4541827 commit 1d1213f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libstd/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ mod tests {
let (a, b) = ($a, $b);
if a != b {
let (a, b) = if a > b {(a, b)} else {(b, a)};
assert!(a - Duration::new(0, 100) <= b);
assert!(a - Duration::new(0, 1000) <= b,
"{:?} is not almost equal to {:?}", a, b);
}
})
}
Expand Down

0 comments on commit 1d1213f

Please sign in to comment.