Esempio n. 1
0
 def test_get_type(self):
     """get_type()"""
     # Check whether the returned value is self.ctype and if
     # equal b_state.types["ColouredState"].
     c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
     self.assertTrue(
         c_state.get_type() == c_state.ctype == types["ColouredState"])
Esempio n. 2
0
 def test_set_id(self):
     """set_id()"""
     # Check whether the adjustable self._id properly.
     c_state = ColouredState(2, set([1]), set([11, 15, 4]))
     self.assertTrue(c_state._id == 2)
     c_state.set_id(15)
     self.assertTrue(c_state._id == 15)
Esempio n. 3
0
 def test_set_colours(self):
     """set_colours()"""
     # Check whether the adjustable self.colours properly.
     c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
     self.assertTrue(c_state.colours == set([11, 14]))
     c_state.set_colours(set([3, 5, 7]))
     self.assertTrue(c_state.colours == set([3, 5, 7]))
Esempio n. 4
0
 def test_get_type(self):
     """get_type()"""
     # Check whether the returned value is self.ctype and if
     # equal b_state.types["ColouredState"].
     c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
     self.assertTrue(c_state.get_type() == c_state.ctype ==
         types["ColouredState"])
Esempio n. 5
0
 def test_set_colours(self):
     """set_colours()"""
     # Check whether the adjustable self.colours properly.
     c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
     self.assertTrue(c_state.colours == set([11, 14]))
     c_state.set_colours(set([3, 5, 7]))
     self.assertTrue(c_state.colours == set([3, 5, 7]))
Esempio n. 6
0
 def test_get_support_type(self):
     """get_support_type()"""
     # Check whether the returned value is self.stypes and if
     # equal to [types["b_State"], types["ColouredState"]]
     c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
     self.assertTrue(c_state.get_support_type() == c_state.stypes ==
         [types["b_State"], types["ColouredState"]])
Esempio n. 7
0
 def test_get_support_type(self):
     """get_support_type()"""
     # Check whether the returned value is self.stypes and if
     # equal to [types["b_State"], types["ColouredState"]]
     c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
     self.assertTrue(c_state.get_support_type() == c_state.stypes ==
                     [types["b_State"], types["ColouredState"]])
Esempio n. 8
0
 def test_set_id(self):
     """set_id()"""
     # Check whether the adjustable self._id properly.
     c_state = ColouredState(2, set([1]), set([11, 15, 4]))
     self.assertTrue(c_state._id == 2)
     c_state.set_id(15)
     self.assertTrue(c_state._id == 15)
Esempio n. 9
0
 def test__str__(self):
     """__str__()"""
     # Determine whether the returned string corresponding to
     # str(self._id) + ", " + str(self.colours). Call the object
     # function str(object).
     c_state = ColouredState(5, set([0]),set([1, 2]))
     self.assertTrue(c_state.__str__() ==
         str(c_state._id) + ", " + str(c_state.colours))
Esempio n. 10
0
 def test__str__(self):
     """__str__()"""
     # Determine whether the returned string corresponding to
     # str(self._id) + ", " + str(self.colours). Call the object
     # function str(object).
     c_state = ColouredState(5, set([0]), set([1, 2]))
     self.assertTrue(c_state.__str__() == str(c_state._id) + ", " +
                     str(c_state.colours))
Esempio n. 11
0
    def test_get_text(self):
        """get_text()"""
        # Check whether the returned value is str(self._id).
        c_state = ColouredState(6, set([0]), set([11]))
        self.assertTrue(c_state.get_text() == "\"6~11\"")

        c_state = ColouredState(0, set([1]), set([11, 15, 4]))
        self.assertTrue(c_state.get_text() == "\"0~11~4~15\"")
Esempio n. 12
0
 def test__repr__(self):
     """__repr__()"""
     # Determine whether the returned string corresponding to
     # "<" + str(self._id) + ", " + str(self._rnum) + ", " +
     # str(self.colours) + ">". To call the object function repr(object).
     c_state = ColouredState(5, set([0]), set([1, 2]))
     self.assertTrue(c_state.__repr__() == "<" + str(c_state._id) + ", " +
                     str(c_state._rnum) + ", " + str(c_state.colours) + ">")
Esempio n. 13
0
 def test__repr__(self):
     """__repr__()"""
     # Determine whether the returned string corresponding to
     # "<" + str(self._id) + ", " + str(self._rnum) + ", " +
     # str(self.colours) + ">". To call the object function repr(object).
     c_state = ColouredState(5, set([0]),set([1, 2]))
     self.assertTrue(c_state.__repr__() ==
         "<" + str(c_state._id) + ", " + str(c_state._rnum) + ", " +
         str(c_state.colours) + ">")
Esempio n. 14
0
    def test_set_join_method(self):
        """set_join_method()"""
        # Check whether the adjustable self.join_method properly.
        c_state = ColouredState(0, set([]), set([1]))
        self.assertTrue(c_state.join_method == "union")

        c_state.set_join_method("difference")
        self.assertTrue(c_state.join_method == "difference")

        c_state.set_join_method("intersection")
        self.assertTrue(c_state.join_method == "intersection")
Esempio n. 15
0
    def test_is_final(self):
        """is_final()"""
        # If len(self._rnum) == 0 then returns False, otherwise it returns True.
        c_state = ColouredState(2, set([]), set([11]))
        self.assertTrue(c_state.is_final() == False)

        c_state = ColouredState(5, set([0]), set([11, 15]))
        self.assertTrue(c_state.is_final() == True)

        c_state = ColouredState(5, set([0, 1, 2]), set([11, 15]))
        self.assertTrue(c_state.is_final() == True)
Esempio n. 16
0
    def test_get_regexp_number(self):
        """get_regexp_number()"""
        # Check whether the returned value is self._rnum.
        c_state = ColouredState(2, set([]), set([11]))
        self.assertTrue(
            c_state.get_regexp_number() == c_state._rnum == set([]))

        c_state = ColouredState(5, set([0]), set([11, 15]))
        self.assertTrue(
            c_state.get_regexp_number() == c_state._rnum == set([0]))

        c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
        self.assertTrue(
            c_state.get_regexp_number() == c_state._rnum == set([0, 1, 2]))
Esempio n. 17
0
    def test_set_regexp_number(self):
        """set_regexp_number()"""
        # Check whether the adjustable self._rnum properly.
        c_state = ColouredState(2, set([]), set([11]))
        self.assertTrue(c_state._rnum == set([]))
        c_state.set_regexp_number(set([1]))
        self.assertTrue(c_state._rnum == set([1]))

        c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
        self.assertTrue(c_state._rnum == set([0, 1, 2]))
        c_state.set_regexp_number(set([1, 3, 5]))
        self.assertTrue(c_state._rnum == set([1, 3, 5]))
Esempio n. 18
0
    def test_get_text(self):
        """get_text()"""
        # Check whether the returned value is str(self._id).
        c_state = ColouredState(6, set([0]), set([11]))
        self.assertTrue(c_state.get_text() == "\"6~11\"")

        c_state = ColouredState(0, set([1]), set([11, 15, 4]))
        self.assertTrue(c_state.get_text() == "\"0~11~4~15\"")
Esempio n. 19
0
    def test_is_final(self):
        """is_final()"""
        # If len(self._rnum) == 0 then returns False, otherwise it returns True.
        c_state = ColouredState(2, set([]), set([11]))
        self.assertTrue(c_state.is_final() == False)

        c_state = ColouredState(5, set([0]), set([11, 15]))
        self.assertTrue(c_state.is_final() == True)

        c_state = ColouredState(5, set([0, 1, 2]), set([11, 15]))
        self.assertTrue(c_state.is_final() == True)
Esempio n. 20
0
    def test_set_join_method(self):
        """set_join_method()"""
        # Check whether the adjustable self.join_method properly.
        c_state = ColouredState(0, set([]), set([1]))
        self.assertTrue(c_state.join_method == "union")

        c_state.set_join_method("difference")
        self.assertTrue(c_state.join_method == "difference")

        c_state.set_join_method("intersection")
        self.assertTrue(c_state.join_method == "intersection")
Esempio n. 21
0
    def test_set_regexp_number(self):
        """set_regexp_number()"""
        # Check whether the adjustable self._rnum properly.
        c_state = ColouredState(2, set([]), set([11]))
        self.assertTrue(c_state._rnum == set([]))
        c_state.set_regexp_number(set([1]))
        self.assertTrue(c_state._rnum == set([1]))

        c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
        self.assertTrue(c_state._rnum == set([0, 1, 2]))
        c_state.set_regexp_number(set([1, 3, 5]))
        self.assertTrue(c_state._rnum == set([1, 3, 5]))
Esempio n. 22
0
    def test_get_regexp_number(self):
        """get_regexp_number()"""
        # Check whether the returned value is self._rnum.
        c_state = ColouredState(2, set([]), set([11]))
        self.assertTrue(c_state.get_regexp_number() == c_state._rnum
            == set([]))

        c_state = ColouredState(5, set([0]), set([11, 15]))
        self.assertTrue(c_state.get_regexp_number() == c_state._rnum
            == set([0]))

        c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
        self.assertTrue(c_state.get_regexp_number() == c_state._rnum
            == set([0, 1, 2]))
Esempio n. 23
0
 def test_get_colours(self):
     """get_colours()"""
     # Check whether the returned value is self.colours.
     c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
     self.assertTrue(
         c_state.get_colours() == c_state.colours == set([11, 14]))
Esempio n. 24
0
 def test_get_id(self):
     """get_id()"""
     # Check whether the returned value is self._id.
     c_state = ColouredState(2, set([1]), set([11, 15, 4]))
     self.assertTrue(c_state.get_id() == c_state._id == 2)
Esempio n. 25
0
    def test_get_join_method(self):
        """get_join_method()"""
        # Check whether the returned value is self.join_method. Check
        # whether the returned value is one of the union, intersection,
        # difference, symmetric_difference.
        c_state = ColouredState(0, set([]), set([1]))
        self.assertTrue(c_state.get_join_method() == c_state.join_method)
        self.assertTrue(c_state.get_join_method() == "union"
                        or c_state.get_join_method() == "intersection"
                        or c_state.get_join_method() == "difference"
                        or c_state.get_join_method() == "symmetric_difference")

        c_state = ColouredState(0, set([]), set([1]), "intersection")
        self.assertTrue(c_state.get_join_method() == c_state.join_method)
        self.assertTrue(c_state.get_join_method() == "union"
                        or c_state.get_join_method() == "intersection"
                        or c_state.get_join_method() == "difference"
                        or c_state.get_join_method() == "symmetric_difference")

        c_state = ColouredState(0, set([]), set([1]), "difference")
        self.assertTrue(c_state.get_join_method() == c_state.join_method)
        self.assertTrue(c_state.get_join_method() == "union"
                        or c_state.get_join_method() == "intersection"
                        or c_state.get_join_method() == "difference"
                        or c_state.get_join_method() == "symmetric_difference")

        c_state = ColouredState(0, set([]), set([1]), "symmetric_difference")
        self.assertTrue(c_state.get_join_method() == c_state.join_method)
        self.assertTrue(c_state.get_join_method() == "union"
                        or c_state.get_join_method() == "intersection"
                        or c_state.get_join_method() == "difference"
                        or c_state.get_join_method() == "symmetric_difference")
Esempio n. 26
0
    def test_compute_join(self):
        """compute_join()"""
        # - Check whether _rnum returned object contains the values of the
        #   two _rnum ColouredState object class.
        # - Check whether the colors returned object contains the values
        #   of colors for the two class object ColouredState()
        #   concentrations under all 4 (union, intersection, difference,
        #   symmetric_difference) connectivity colors - join_method attribute.
        # - If join_method other than 4 appear at the top, check thrown.
        # - Check whether the returned object _id is equal to -2.
        c_state = ColouredState(5, set([0]), set([1, 2]), "union")
        other_state = ColouredState(6, set([1]), set([3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([0, 1]))
        self.assertTrue(join_state.colours == set([1, 2, 3, 4]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([0]), set([1, 2]), "intersection")
        other_state = ColouredState(6, set([1]), set([3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([0, 1]))
        self.assertTrue(join_state.colours == set([]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([0]), set([1, 2, 3, 4]), "intersection")
        other_state = ColouredState(6, set([1]), set([3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([0, 1]))
        self.assertTrue(join_state.colours == set([3, 4]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([]), set([1, 2]), "difference")
        other_state = ColouredState(6, set([]), set([3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([]))
        self.assertTrue(join_state.colours == set([1, 2]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([1, 2]), set([1, 2]), "difference")
        other_state = ColouredState(6, set([3, 4]), set([2, 3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([1, 2, 3, 4]))
        self.assertTrue(join_state.colours == set([1]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([0]), set([1, 2, 3]),
                                "symmetric_difference")
        other_state = ColouredState(6, set([1]), set([3, 4, 5]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([0, 1]))
        self.assertTrue(join_state.colours == set([1, 2, 4, 5]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([0]), set([1, 2]), "error_join")
        other_state = ColouredState(6, set([1]), set([3, 4]))
        try:
            c_state.compute_join(other_state)
            self.assertTrue(False)
        except state_colour_operation_not_supported_exception:
            self.assertTrue(True)
Esempio n. 27
0
    def test_join(self):
        """join()"""
        # Check whether _rnum of returned object contains values of
        # two _rnum b_State() class objects.
        # Create a class object ColouredState and try whether there would
        # be successful united in cases:
        #   - the self is ColouredState
        #   - other is ColouredState

        # SAME CODE AS IN "test_b_state.py"

        # check join two b_State - self join other
        self_state = b_State()
        other_state = b_State()
        self.assertTrue((self_state.join(other_state))._rnum == set())

        self_state = b_State()
        self_state._rnum = set([0])
        other_state = b_State()
        self.assertTrue((self_state.join(other_state))._rnum == set([0]))

        self_state = b_State()
        other_state = b_State()
        other_state._rnum = set([0])
        self.assertTrue((self_state.join(other_state))._rnum == set([0]))

        self_state = b_State()
        self_state._rnum = set([0])
        other_state = b_State()
        other_state._rnum = set([1])
        self.assertTrue((self_state.join(other_state))._rnum == set([0, 1]))

        # check join two b_State - other join self
        self_state = b_State()
        other_state = b_State()
        self.assertTrue((other_state.join(self_state))._rnum == set())

        self_state = b_State()
        self_state._rnum = set([0])
        other_state = b_State()
        self.assertTrue((other_state.join(self_state))._rnum == set([0]))

        self_state = b_State()
        other_state = b_State()
        other_state._rnum = set([0])
        self.assertTrue((other_state.join(self_state))._rnum == set([0]))

        self_state = b_State()
        self_state._rnum = set([0])
        other_state = b_State()
        other_state._rnum = set([1])
        self.assertTrue((other_state.join(self_state))._rnum == set([0, 1]))

        # self is ColouredState class and other is b_State class
        self_state = ColouredState(0, set([11]), set([1]))
        other_state = b_State(1, set([15]))
        self.assertTrue((self_state.join(other_state))._rnum == set([11, 15]))

        self_state = ColouredState(2, set([14]), set([1]))
        other_state = b_State(3, set([2, 3]))
        self.assertTrue(
            (other_state.join(self_state))._rnum == set([2, 3, 14]))

        # try error
        self_state.stypes = []
        try:
            self_state.join(other_state)
            self.assertTrue(False)
        except state_join_exception:
            self.assertTrue(True)

        # ColouredState - self join other
        self_state = ColouredState(0, set([]), set([1]))
        other_state = ColouredState(1, set([]), set([5]))
        self.assertTrue((self_state.join(other_state))._rnum == set())

        self_state = ColouredState(0, set([0]), set([1]))
        other_state = ColouredState(1, set([]), set([5]))
        self.assertTrue((self_state.join(other_state))._rnum == set([0]))

        self_state = ColouredState(0, set([0]), set([1]))
        other_state = ColouredState(1, set([1]), set([5]))
        self.assertTrue((self_state.join(other_state))._rnum == set([0, 1]))

        # ColouredState - other join self
        self_state = ColouredState(0, set([]), set([1]))
        other_state = ColouredState(1, set([]), set([5]))
        self.assertTrue((other_state.join(self_state))._rnum == set())

        self_state = ColouredState(0, set([0]), set([1]))
        other_state = ColouredState(1, set([]), set([5]))
        self.assertTrue((other_state.join(self_state))._rnum == set([0]))

        self_state = ColouredState(0, set([]), set([1]))
        other_state = ColouredState(1, set([1]), set([5]))
        self.assertTrue((other_state.join(self_state))._rnum == set([1]))

        self_state = ColouredState(0, set([0]), set([1]))
        other_state = ColouredState(1, set([1]), set([5]))
        self.assertTrue((other_state.join(self_state))._rnum == set([0, 1]))
Esempio n. 28
0
 def test_get_id(self):
     """get_id()"""
     # Check whether the returned value is self._id.
     c_state = ColouredState(2, set([1]), set([11, 15, 4]))
     self.assertTrue(c_state.get_id() == c_state._id == 2)
Esempio n. 29
0
    def test_compute_join(self):
        """compute_join()"""
        # - Check whether _rnum returned object contains the values of the
        #   two _rnum ColouredState object class.
        # - Check whether the colors returned object contains the values
        #   of colors for the two class object ColouredState()
        #   concentrations under all 4 (union, intersection, difference,
        #   symmetric_difference) connectivity colors - join_method attribute.
        # - If join_method other than 4 appear at the top, check thrown.
        # - Check whether the returned object _id is equal to -2.
        c_state = ColouredState(5, set([0]), set([1, 2]), "union")
        other_state = ColouredState(6, set([1]), set([3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([0,1]))
        self.assertTrue(join_state.colours == set([1,2,3,4]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([0]), set([1, 2]), "intersection")
        other_state = ColouredState(6, set([1]), set([3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([0,1]))
        self.assertTrue(join_state.colours == set([]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([0]), set([1, 2, 3, 4]), "intersection")
        other_state = ColouredState(6, set([1]), set([3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([0,1]))
        self.assertTrue(join_state.colours == set([3,4]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([]), set([1, 2]), "difference")
        other_state = ColouredState(6, set([]), set([3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([]))
        self.assertTrue(join_state.colours == set([1,2]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([1,2]), set([1, 2]), "difference")
        other_state = ColouredState(6, set([3,4]), set([2,3, 4]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([1,2,3,4]))
        self.assertTrue(join_state.colours == set([1]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([0]),set([1,2,3]),"symmetric_difference")
        other_state = ColouredState(6, set([1]), set([3,4,5]))
        join_state = c_state.compute_join(other_state)
        self.assertTrue(join_state._rnum == set([0,1]))
        self.assertTrue(join_state.colours == set([1,2,4,5]))
        self.assertTrue(join_state._id == -2)

        c_state = ColouredState(5, set([0]),set([1,2]),"error_join")
        other_state = ColouredState(6, set([1]), set([3,4]))
        try:
            c_state.compute_join(other_state)
            self.assertTrue(False)
        except state_colour_operation_not_supported_exception:
            self.assertTrue(True)
Esempio n. 30
0
    def test_join(self):
        """join()"""
        # Check whether _rnum of returned object contains values of
        # two _rnum b_State() class objects.
        # Create a class object ColouredState and try whether there would
        # be successful united in cases:
        #   - the self is ColouredState
        #   - other is ColouredState

        # SAME CODE AS IN "test_b_state.py"

        # check join two b_State - self join other
        self_state = b_State()
        other_state = b_State()
        self.assertTrue((self_state.join(other_state))._rnum == set())

        self_state = b_State()
        self_state._rnum = set([0])
        other_state = b_State()
        self.assertTrue((self_state.join(other_state))._rnum == set([0]))

        self_state = b_State()
        other_state = b_State()
        other_state._rnum = set([0])
        self.assertTrue((self_state.join(other_state))._rnum == set([0]))

        self_state = b_State()
        self_state._rnum = set([0])
        other_state = b_State()
        other_state._rnum = set([1])
        self.assertTrue((self_state.join(other_state))._rnum == set([0,1]))

        # check join two b_State - other join self
        self_state = b_State()
        other_state = b_State()
        self.assertTrue((other_state.join(self_state))._rnum == set())

        self_state = b_State()
        self_state._rnum = set([0])
        other_state = b_State()
        self.assertTrue((other_state.join(self_state))._rnum == set([0]))

        self_state = b_State()
        other_state = b_State()
        other_state._rnum = set([0])
        self.assertTrue((other_state.join(self_state))._rnum == set([0]))

        self_state = b_State()
        self_state._rnum = set([0])
        other_state = b_State()
        other_state._rnum = set([1])
        self.assertTrue((other_state.join(self_state))._rnum == set([0,1]))

        # self is ColouredState class and other is b_State class
        self_state = ColouredState(0, set([11]), set([1]))
        other_state = b_State(1, set([15]))
        self.assertTrue((self_state.join(other_state))._rnum == set([11, 15]))

        self_state = ColouredState(2, set([14]), set([1]))
        other_state = b_State(3, set([2, 3]))
        self.assertTrue((other_state.join(self_state))._rnum == set([2,3,14]))

        # try error
        self_state.stypes = []
        try :
            self_state.join(other_state)
            self.assertTrue(False)
        except state_join_exception:
            self.assertTrue(True)

        # ColouredState - self join other
        self_state = ColouredState(0, set([]), set([1]))
        other_state = ColouredState(1, set([]), set([5]))
        self.assertTrue((self_state.join(other_state))._rnum == set())

        self_state = ColouredState(0, set([0]), set([1]))
        other_state = ColouredState(1, set([]), set([5]))
        self.assertTrue((self_state.join(other_state))._rnum == set([0]))

        self_state = ColouredState(0, set([0]), set([1]))
        other_state = ColouredState(1, set([1]), set([5]))
        self.assertTrue((self_state.join(other_state))._rnum == set([0, 1]))

        # ColouredState - other join self
        self_state = ColouredState(0, set([]), set([1]))
        other_state = ColouredState(1, set([]), set([5]))
        self.assertTrue((other_state.join(self_state))._rnum == set())

        self_state = ColouredState(0, set([0]), set([1]))
        other_state = ColouredState(1, set([]), set([5]))
        self.assertTrue((other_state.join(self_state))._rnum == set([0]))

        self_state = ColouredState(0, set([]), set([1]))
        other_state = ColouredState(1, set([1]), set([5]))
        self.assertTrue((other_state.join(self_state))._rnum == set([1]))

        self_state = ColouredState(0, set([0]), set([1]))
        other_state = ColouredState(1, set([1]), set([5]))
        self.assertTrue((other_state.join(self_state))._rnum == set([0, 1]))
Esempio n. 31
0
 def test_get_colours(self):
     """get_colours()"""
     # Check whether the returned value is self.colours.
     c_state = ColouredState(7, set([0, 1, 2]), set([11, 14]))
     self.assertTrue(c_state.get_colours() == c_state.colours ==
         set([11, 14]))
Esempio n. 32
0
    def test_get_join_method(self):
        """get_join_method()"""
        # Check whether the returned value is self.join_method. Check
        # whether the returned value is one of the union, intersection,
        # difference, symmetric_difference.
        c_state = ColouredState(0, set([]), set([1]))
        self.assertTrue(c_state.get_join_method() == c_state.join_method)
        self.assertTrue(c_state.get_join_method() == "union"
            or c_state.get_join_method() == "intersection"
            or c_state.get_join_method() == "difference"
            or c_state.get_join_method() == "symmetric_difference"
        )

        c_state = ColouredState(0, set([]), set([1]), "intersection")
        self.assertTrue(c_state.get_join_method() == c_state.join_method)
        self.assertTrue(c_state.get_join_method() == "union"
            or c_state.get_join_method() == "intersection"
            or c_state.get_join_method() == "difference"
            or c_state.get_join_method() == "symmetric_difference"
        )

        c_state = ColouredState(0, set([]), set([1]), "difference")
        self.assertTrue(c_state.get_join_method() == c_state.join_method)
        self.assertTrue(c_state.get_join_method() == "union"
            or c_state.get_join_method() == "intersection"
            or c_state.get_join_method() == "difference"
            or c_state.get_join_method() == "symmetric_difference"
        )

        c_state = ColouredState(0, set([]), set([1]), "symmetric_difference")
        self.assertTrue(c_state.get_join_method() == c_state.join_method)
        self.assertTrue(c_state.get_join_method() == "union"
            or c_state.get_join_method() == "intersection"
            or c_state.get_join_method() == "difference"
            or c_state.get_join_method() == "symmetric_difference"
        )