[gnome-calculator/wip/mpc: 4/5] Add test for equals
- From: Phillip Wood <pwood src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator/wip/mpc: 4/5] Add test for equals
- Date: Fri, 22 Jan 2016 11:41:24 +0000 (UTC)
commit a599408bfb6a95efb6c67a5e631b123a55230f55
Author: Phillip Wood <phillip wood dunelm org uk>
Date: Sun Jan 17 14:38:28 2016 +0000
Add test for equals
tests/test-number.vala | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-number.vala b/tests/test-number.vala
index cb346a4..bbc6718 100644
--- a/tests/test-number.vala
+++ b/tests/test-number.vala
@@ -619,6 +619,31 @@ private void test_logarithm10 ()
pass ();
}
+private void test_equals ()
+{
+ for (var a = -10; a <= 10; a++)
+ {
+ for (var b = -10; b <= 10; b++)
+ {
+ for (var c = -10; c <= 10; c++)
+ {
+ for (var d = -10; d <= 10; d++)
+ {
+ var x = new Number.double (a ,b);
+ var y = new Number.double (c, d);
+ var expected = a == c && b == d;
+ if (x.equals (y) != expected) {
+ fail ("(%d, %d).is_equal (%d, %d) -> %s, expected %s".printf (a ,b, c, d, x.equals
(y) ? "true" : "false", expected ? "true" : "false"));
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ pass ();
+}
+
private void test_is_zero ()
{
for (var a = -10; a <= 10; a++)
@@ -1139,6 +1164,7 @@ static int main (string[] args)
//test_ones_complement ();
//test_twos_complement ();
test_factorize ();
+ test_equals ();
if (fail_count == 0)
stdout.printf ("Passed all %i tests\n", pass_count);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]