@@ -9,6 +9,13 @@ import OSCKitCore
99import Testing
1010
1111@Suite struct OSCTimeTag_Tests {
12+ #if os(macOS) || os(iOS)
13+ let tolerance : TimeInterval = 0.001
14+ #elseif os(tvOS) || os(watchOS)
15+ // allow more time variance for CI pipeline to de-flake
16+ let tolerance : TimeInterval = 0.01
17+ #endif
18+
1219 @Test func init_RawValue( ) {
1320 // ensure all raw values including 0 and 1 are allowed
1421 #expect( OSCTimeTag ( 0 ) . rawValue == 0 )
@@ -40,8 +47,7 @@ import Testing
4047 #expect( !tag. isImmediate)
4148 #expect( !tag. isFuture)
4249 #expect( tag. date < Date ( ) )
43- #expect( tag. timeIntervalSinceNow ( ) . isApproximatelyEqual ( to: - 10.0 , absoluteTolerance: 0.001 ) )
44-
50+ #expect( tag. timeIntervalSinceNow ( ) . isApproximatelyEqual ( to: - 10.0 , absoluteTolerance: tolerance) )
4551 }
4652
4753 // MARK: - .init(timeIntervalSince1900:)
@@ -148,13 +154,13 @@ import Testing
148154 @Test func immediate_date( ) {
149155 let tag = OSCTimeTag . immediate ( )
150156 let date = Date ( )
151- #expect( tag. date. timeIntervalSince ( date) . isApproximatelyEqual ( to: 0.0 , absoluteTolerance: 0.001 ) )
157+ #expect( tag. date. timeIntervalSince ( date) . isApproximatelyEqual ( to: 0.0 , absoluteTolerance: tolerance ) )
152158 }
153159
154160 @Test func immediate_timeIntervalSinceNow( ) {
155161 let tag = OSCTimeTag . immediate ( )
156162 let captureSecondsFromNow = tag. timeIntervalSinceNow ( )
157- #expect( captureSecondsFromNow. isApproximatelyEqual ( to: 0.0 , absoluteTolerance: 0.001 ) )
163+ #expect( captureSecondsFromNow. isApproximatelyEqual ( to: 0.0 , absoluteTolerance: tolerance ) )
158164 }
159165
160166 // MARK: - .now()
@@ -182,14 +188,14 @@ import Testing
182188 @Test func now_date( ) {
183189 let tag = OSCTimeTag . now ( )
184190 let captureDate = tag. date
185- #expect( Date ( ) . timeIntervalSince ( captureDate) . isApproximatelyEqual ( to: 0.0 , absoluteTolerance: 0.001 ) )
191+ #expect( Date ( ) . timeIntervalSince ( captureDate) . isApproximatelyEqual ( to: 0.0 , absoluteTolerance: tolerance ) )
186192
187193 }
188194
189195 @Test func now_timeIntervalSinceNow( ) {
190196 let tag = OSCTimeTag . now ( )
191197 let captureSecondsFromNow = tag. timeIntervalSinceNow ( )
192- #expect( captureSecondsFromNow. isApproximatelyEqual ( to: 0.0 , absoluteTolerance: 0.001 ) )
198+ #expect( captureSecondsFromNow. isApproximatelyEqual ( to: 0.0 , absoluteTolerance: tolerance ) )
193199 }
194200}
195201
0 commit comments