aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/tests/common.vala
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/tests/common.vala')
-rw-r--r--xmpp-vala/tests/common.vala17
1 files changed, 17 insertions, 0 deletions
diff --git a/xmpp-vala/tests/common.vala b/xmpp-vala/tests/common.vala
index 47dbce0e..dc1c8e50 100644
--- a/xmpp-vala/tests/common.vala
+++ b/xmpp-vala/tests/common.vala
@@ -6,6 +6,7 @@ int main(string[] args) {
TestSuite.get_root().add_suite(new Xmpp.Test.StanzaTest().get_suite());
TestSuite.get_root().add_suite(new Xmpp.Test.UtilTest().get_suite());
TestSuite.get_root().add_suite(new Xmpp.Test.JidTest().get_suite());
+ TestSuite.get_root().add_suite(new Xmpp.Test.ColorTest().get_suite());
return GLib.Test.run();
}
@@ -68,6 +69,22 @@ bool fail_if_not_eq_int(int left, int right, string? reason = null) {
return fail_if_not(left == right, @"$(reason + ": " ?? "")$left != $right");
}
+private float float_to_accuracy(float f, float accuracy) {
+ return (float) (Math.round(f * Math.pow(10, accuracy)) / Math.pow(10, accuracy));
+}
+
+private float double_to_accuracy(double f, float accuracy) {
+ return (float) (Math.round(f * Math.pow(10, accuracy)) / Math.pow(10, accuracy));
+}
+
+bool fail_if_not_eq_float(float left, float right, float accuracy = 3, string? reason = null) {
+ return fail_if_not(float_to_accuracy(left, accuracy) == float_to_accuracy(right, accuracy), @"$(reason + ": " ?? "")$left != $right");
+}
+
+bool fail_if_not_eq_double(double left, double right, float accuracy = 3, string? reason = null) {
+ return fail_if_not(double_to_accuracy(left, accuracy) == double_to_accuracy(right, accuracy), @"$(reason + ": " ?? "")$left != $right");
+}
+
bool fail_if_not_eq_str(string? left, string? right, string? reason = null) {
bool nullcheck = (left == null || right == null) && (left != null && right != null);
if (left == null) left = "(null)";