changeset 919:6d14c1d7c92d

Test of probabilistic equality mixin.
author Sigurd Meldgaard <stm@daimi.au.dk>
date Tue, 16 Sep 2008 16:11:10 +0200
parents 83c89640a6ee
children 53fde6bf9230
files viff/test/test_runtime_equal.py
diffstat 1 files changed, 69 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/viff/test/test_runtime_equal.py	Tue Sep 16 16:11:10 2008 +0200
@@ -0,0 +1,69 @@
+# Copyright 2008 VIFF Development Team.
+#
+# This file is part of VIFF, the Virtual Ideal Functionality Framework.
+#
+# VIFF is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License (LGPL) as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VIFF is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
+
+
+"""Tests of the equality protocol(s)."""
+
+import operator
+
+from viff.equality import ProbabilisticEqualityMixin
+from viff.test.util import RuntimeTestCase, BinaryOperatorTestCase
+from viff.runtime import Runtime
+
+#: Declare doctests for Trial.
+__doctests__ = ['viff.equality']
+
+
+class EqualRuntime(Runtime, ProbabilisticEqualityMixin):
+    """A runtime with the equality mixin."""
+    pass
+
+
+class ProbabilisticEqualityTestDifferent(BinaryOperatorTestCase,
+                                         RuntimeTestCase):
+    """Testing the equality with *a* and *b* different."""
+    # Arbitrarily chosen.
+    a = 12442
+    b = 91243
+    runtime_class = EqualRuntime
+    operator = operator.eq
+
+
+class ProbabilisticEqualityTestEqual(BinaryOperatorTestCase, RuntimeTestCase):
+    """Testing the equality with *a* and *b* equal."""
+    a = 4023
+    b = 4023
+    runtime_class = EqualRuntime
+    operator = operator.eq
+
+
+class ProbabilisticEqualityTestDiff1_1(BinaryOperatorTestCase,
+                                       RuntimeTestCase):
+    """Testing ``a == b`` where ``b = a + 1``."""
+    a = 0
+    b = 1
+    runtime_class = EqualRuntime
+    operator = operator.eq
+
+
+class ProbabilisticEqualityTestDiff1_2(BinaryOperatorTestCase,
+                                       RuntimeTestCase):
+    """Testing ``a == b`` where ``a = b + 1``."""
+    a = 1
+    b = 0
+    runtime_class = EqualRuntime
+    operator = operator.eq