klingtnet / rosc

An OSC library for Rust.
Apache License 2.0
173 stars 25 forks source link

Fix unit tests on Windows #35

Closed maxnoel closed 2 years ago

maxnoel commented 2 years ago

On Windows, the resolution of SystemTime is 100ns, as opposed to 1ns on UNIX (https://doc.rust-lang.org/std/time/struct.SystemTime.html#platform-specific-behavior).

As a result, any conversion of OscTime to SystemTime results in the latter being quantized to the nearest 100ns (rounded down). This also means both types of round-trips are lossy: for any time t, t + i roundtrips to t for all 0ns <= i < 100ns.

Increase the tolerance for equality on Windows only to 100ns instead of 5 to compensate for that, which in turn makes the unit tests pass on Windows.

klingtnet commented 2 years ago

@maxnoel Thank you for your 2nd contribution 🎉! I've no Windows machine available, so I'm pretty happy to receive a bugfix for this system. Also, the good PR description is appreciated 😊