diff --git a/src/CSFML/System/Time.cpp b/src/CSFML/System/Time.cpp index 4b7b3161..00bd6144 100644 --- a/src/CSFML/System/Time.cpp +++ b/src/CSFML/System/Time.cpp @@ -63,7 +63,7 @@ sfTime sfSeconds(float amount) //////////////////////////////////////////////////////////// sfTime sfMilliseconds(int32_t amount) { - return {static_cast(amount * 1000)}; + return {int64_t{amount} * 1000}; } diff --git a/test/System/Time.test.cpp b/test/System/Time.test.cpp index 32f0fc1a..c58b3b0f 100644 --- a/test/System/Time.test.cpp +++ b/test/System/Time.test.cpp @@ -28,4 +28,7 @@ TEST_CASE("[System] sfTime") CHECK(sfSeconds(10).microseconds == 10'000'000); CHECK(sfMilliseconds(10).microseconds == 10'000); CHECK(sfMicroseconds(10).microseconds == 10); + + CHECK(sfMilliseconds(std::numeric_limits::max()).microseconds == 2'147'483'647'000); + CHECK(sfMicroseconds(std::numeric_limits::max()).microseconds == std::numeric_limits::max()); }