viff

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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/viff/test/test_runtime_equal.py	Tue Sep 16 16:11:10 2008 +0200
     1.3 @@ -0,0 +1,69 @@
     1.4 +# Copyright 2008 VIFF Development Team.
     1.5 +#
     1.6 +# This file is part of VIFF, the Virtual Ideal Functionality Framework.
     1.7 +#
     1.8 +# VIFF is free software: you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU Lesser General Public License (LGPL) as
    1.10 +# published by the Free Software Foundation, either version 3 of the
    1.11 +# License, or (at your option) any later version.
    1.12 +#
    1.13 +# VIFF is distributed in the hope that it will be useful, but WITHOUT
    1.14 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    1.15 +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
    1.16 +# Public License for more details.
    1.17 +#
    1.18 +# You should have received a copy of the GNU Lesser General Public
    1.19 +# License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
    1.20 +
    1.21 +
    1.22 +"""Tests of the equality protocol(s)."""
    1.23 +
    1.24 +import operator
    1.25 +
    1.26 +from viff.equality import ProbabilisticEqualityMixin
    1.27 +from viff.test.util import RuntimeTestCase, BinaryOperatorTestCase
    1.28 +from viff.runtime import Runtime
    1.29 +
    1.30 +#: Declare doctests for Trial.
    1.31 +__doctests__ = ['viff.equality']
    1.32 +
    1.33 +
    1.34 +class EqualRuntime(Runtime, ProbabilisticEqualityMixin):
    1.35 +    """A runtime with the equality mixin."""
    1.36 +    pass
    1.37 +
    1.38 +
    1.39 +class ProbabilisticEqualityTestDifferent(BinaryOperatorTestCase,
    1.40 +                                         RuntimeTestCase):
    1.41 +    """Testing the equality with *a* and *b* different."""
    1.42 +    # Arbitrarily chosen.
    1.43 +    a = 12442
    1.44 +    b = 91243
    1.45 +    runtime_class = EqualRuntime
    1.46 +    operator = operator.eq
    1.47 +
    1.48 +
    1.49 +class ProbabilisticEqualityTestEqual(BinaryOperatorTestCase, RuntimeTestCase):
    1.50 +    """Testing the equality with *a* and *b* equal."""
    1.51 +    a = 4023
    1.52 +    b = 4023
    1.53 +    runtime_class = EqualRuntime
    1.54 +    operator = operator.eq
    1.55 +
    1.56 +
    1.57 +class ProbabilisticEqualityTestDiff1_1(BinaryOperatorTestCase,
    1.58 +                                       RuntimeTestCase):
    1.59 +    """Testing ``a == b`` where ``b = a + 1``."""
    1.60 +    a = 0
    1.61 +    b = 1
    1.62 +    runtime_class = EqualRuntime
    1.63 +    operator = operator.eq
    1.64 +
    1.65 +
    1.66 +class ProbabilisticEqualityTestDiff1_2(BinaryOperatorTestCase,
    1.67 +                                       RuntimeTestCase):
    1.68 +    """Testing ``a == b`` where ``a = b + 1``."""
    1.69 +    a = 1
    1.70 +    b = 0
    1.71 +    runtime_class = EqualRuntime
    1.72 +    operator = operator.eq