From 2fce1d6cec6ffd1775bfa05ce8d5d48450100051 Mon Sep 17 00:00:00 2001 From: Prachi Gauriar Date: Wed, 22 Oct 2025 22:34:56 -0400 Subject: [PATCH] Use randomPrintable(in:using:) to generate time intervals --- CHANGELOG.md | 7 +++++++ .../DevTesting/Random Value Generation/Date+Random.swift | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bef5b54..3ab25df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # DevTesting Changelog +## 1.5.0: October 22, 2025 + +The `Date.random(in:using:)` functions now use `BinaryFloatingPoint.randomPrintable(in:using:)` to +generate time intervals. This should lead to greater reliability when converting the time intervals +of generated dates into strings. + + ## 1.4.0: October 12, 2025 `Stub` and `ThrowingStub` now conform to `Observable`. The only property that is tracked is diff --git a/Sources/DevTesting/Random Value Generation/Date+Random.swift b/Sources/DevTesting/Random Value Generation/Date+Random.swift index c0c8c68..7425ca5 100644 --- a/Sources/DevTesting/Random Value Generation/Date+Random.swift +++ b/Sources/DevTesting/Random Value Generation/Date+Random.swift @@ -21,7 +21,7 @@ extension Date { let lowerBound = range.lowerBound.timeIntervalSinceReferenceDate let upperBound = range.upperBound.timeIntervalSinceReferenceDate return Date( - timeIntervalSinceReferenceDate: .random( + timeIntervalSinceReferenceDate: .randomPrintable( in: lowerBound ..< upperBound, using: &generator ) @@ -42,7 +42,7 @@ extension Date { let lowerBound = range.lowerBound.timeIntervalSinceReferenceDate let upperBound = range.upperBound.timeIntervalSinceReferenceDate return Date( - timeIntervalSinceReferenceDate: .random( + timeIntervalSinceReferenceDate: .randomPrintable( in: lowerBound ... upperBound, using: &generator )