Fix for floating point durations

The duration calculation was using %, but that's only supported on
duration objects when the arithmetic type supports %, and hence fails
for floats.  Fixed by subtracting off the calculated values instead.
This commit is contained in:
Jason Rhinelander
2017-03-11 22:29:25 -04:00
parent 28a837a07e
commit e5456c2226
3 changed files with 16 additions and 4 deletions

View File

@@ -104,7 +104,7 @@ def test_chrono_steady_clock_roundtrip():
def test_floating_point_duration():
from pybind11_tests import test_chrono7
from pybind11_tests import test_chrono7, test_chrono_float_diff
import datetime
# Test using 35.525123 seconds as an example floating point number in seconds
@@ -114,3 +114,7 @@ def test_floating_point_duration():
assert time.seconds == 35
assert 525122 <= time.microseconds <= 525123
diff = test_chrono_float_diff(43.789012, 1.123456)
assert diff.seconds == 42
assert 665556 <= diff.microseconds <= 665557