From f939e35dd4f3d22170de64f6b6ca8496af3ad543 Mon Sep 17 00:00:00 2001 From: Chloe McKnight Date: Wed, 15 Jan 2025 10:56:03 -0600 Subject: [PATCH] adjust futures test tolerances Signed-off-by: Chloe McKnight --- dotnet-tests/UniffiCS.BindingTests/TestFutures.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dotnet-tests/UniffiCS.BindingTests/TestFutures.cs b/dotnet-tests/UniffiCS.BindingTests/TestFutures.cs index dc0c443..64bdad9 100644 --- a/dotnet-tests/UniffiCS.BindingTests/TestFutures.cs +++ b/dotnet-tests/UniffiCS.BindingTests/TestFutures.cs @@ -21,12 +21,16 @@ static async Task MeasureTimeMillis(Func callback) { static async Task ReturnsImmediately(Func callback) { var time = await MeasureTimeMillis(callback); - AssertApproximateTime(0, 4, time); + AssertApproximateTime(0, 20, time); } static async Task ReturnsIn(long expected, Func callback) { + await ReturnsIn(expected, 50, callback); + } + + static async Task ReturnsIn(long expected, long tolerance, Func callback) { var time = await MeasureTimeMillis(callback); - AssertApproximateTime(expected, 50, time); + AssertApproximateTime(expected, tolerance, time); } static void AssertApproximateTime(long expected, long tolerance, long actual) { @@ -116,7 +120,7 @@ public async void TestAsyncFallibleFunctions() { await ReturnsImmediately(async () => { await FuturesMethods.FallibleMe(false); await Assert.ThrowsAsync(() => FuturesMethods.FallibleMe(true)); - using (var megaphone = FuturesMethods.NewMegaphone()) { + using (var megaphone = FuturesMethods.NewMegaphone()) { Assert.Equal(42, await megaphone.FallibleMe(false)); await Assert.ThrowsAsync(() => megaphone.FallibleMe(true)); } @@ -144,7 +148,7 @@ await ReturnsImmediately(async () => { [Fact] public async void TestBrokenSleep() { - await ReturnsIn(500, async () => { + await ReturnsIn(500, 100, async () => { // calls the waker twice immediately await FuturesMethods.BrokenSleep(100, 0); // wait for possible failure