Widen test bound to avoid flakiness (#708)

This commit is contained in:
Jake Wharton
2025-02-18 13:46:32 -05:00
committed by GitHub
parent e0b160f069
commit 5a2a78d87d

View File

@ -80,21 +80,21 @@ class PlatformInputTest {
}
@Test fun readWithTimeoutReturnsZeroOnTimeout() {
// The timeouts passed are slightly higher than those validated thanks to Windows which
// can return _slightly_ early. Usually it's around .1ms, but we go 10ms to be sure.
// Windows appears to be happy to return a few milliseconds early, so we just validate a
// conservative lower bound which indicates that there was at least _some_ waiting.
val readA: Int
val tookA = measureTime {
readA = input.readWithTimeout(ByteArray(10), 0, 10, 110)
readA = input.readWithTimeout(ByteArray(10), 0, 10, 100)
}
assertThat(readA).isZero()
assertThat(tookA).isGreaterThan(100.milliseconds)
assertThat(tookA).isGreaterThan(50.milliseconds)
val readB: Int
val tookB = measureTime {
readB = input.readWithTimeout(ByteArray(10), 0, 10, 110)
readB = input.readWithTimeout(ByteArray(10), 0, 10, 100)
}
assertThat(readB).isZero()
assertThat(tookB).isGreaterThan(100.milliseconds)
assertThat(tookB).isGreaterThan(50.milliseconds)
}
}