[geary/mjog/imap-connection-fixes: 31/42] Add TestCase.assert_double
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/imap-connection-fixes: 31/42] Add TestCase.assert_double
- Date: Wed, 25 Mar 2020 22:02:48 +0000 (UTC)
commit 5a4509d3a8b4d8b8e86cac532deca0193e9bfd26
Author: Michael Gratton <mike vee net>
Date: Sun Dec 29 17:00:07 2019 +1030
Add TestCase.assert_double
test/engine/util-timeout-manager-test.vala | 10 +++-------
test/test-case.vala | 4 ++++
2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/test/engine/util-timeout-manager-test.vala b/test/engine/util-timeout-manager-test.vala
index a9a01a64..dcecba8d 100644
--- a/test/engine/util-timeout-manager-test.vala
+++ b/test/engine/util-timeout-manager-test.vala
@@ -87,7 +87,7 @@ class Geary.TimeoutManagerTest : TestCase {
this.main_loop.iteration(true);
}
- assert_epsilon(timer.elapsed(), 1.0, SECONDS_EPSILON);
+ assert_double(timer.elapsed(), 1.0, SECONDS_EPSILON);
}
public void milliseconds() throws Error {
@@ -101,7 +101,7 @@ class Geary.TimeoutManagerTest : TestCase {
this.main_loop.iteration(true);
}
- assert_epsilon(timer.elapsed(), 0.1, MILLISECONDS_EPSILON);
+ assert_double(timer.elapsed(), 0.1, MILLISECONDS_EPSILON);
}
public void repeat_forever() throws Error {
@@ -118,11 +118,7 @@ class Geary.TimeoutManagerTest : TestCase {
}
timer.stop();
- assert_epsilon(timer.elapsed(), 2.0, SECONDS_EPSILON * 2);
- }
-
- private inline void assert_epsilon(double actual, double expected, double epsilon) {
- assert(actual + epsilon >= expected && actual - epsilon <= expected);
+ assert_double(timer.elapsed(), 2.0, SECONDS_EPSILON * 2);
}
}
diff --git a/test/test-case.vala b/test/test-case.vala
index 7e65603d..6292c498 100644
--- a/test/test-case.vala
+++ b/test/test-case.vala
@@ -96,6 +96,10 @@ public void assert_int64(int64 expected, int64 actual, string? context = null)
}
}
+public void assert_double(double actual, double expected, double epsilon) {
+ assert(actual + epsilon >= expected && actual - epsilon <= expected);
+}
+
public void assert_uint(uint expected, uint actual, string? context = null)
throws GLib.Error {
if (expected != actual) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]