Пример #1
0
    def test_determinize(self):
        """
        This ensures that all pre-built test cases work.
        """
        for i in range(len(self.automata)):
            # Get the answer
            ans = None
            with open(self.filenames[i][:-2] + "out") as f:
                ans = json.load(f)

            # Get the determinization of the appropriate automaton
            result = determinize(self.automata[i])

            # Print
            # helper.pretty_print(result)
            # helper.pretty_print(ans)

            # Check answer, making sure it's OK if elements not in order
            self.assertEqual(converter.convert_to_sets(result), converter.convert_to_sets(ans))
Пример #2
0
    def test_accessible(self):
        """
        This ensures that all pre-built test cases work.
        """
        for i in range(len(self.automata)):
            # Get the answer
            ans = None
            with open(self.filenames[i][:-3] + ".out") as f:
                ans = json.load(f)

            # Get the arena for the appropriate automaton
            result = get_accessible(self.automata[i])

            # Print
            # helper.pretty_print(result["states"]["bad"])
            # helper.pretty_print(result)

            # Check answer, making sure it's OK if elements not in order
            self.assertEqual(converter.convert_to_sets(result), converter.convert_to_sets(ans))
Пример #3
0
    def test_union(self):
        """
        This ensures that all pre-built test cases work.
        """
        for i in range(len(self.automata1)):
            # Get the answer
            ans = None
            with open("tests/union/union_test_cases/union_test_" + str(i + 1) +
                      ".out") as f:
                ans = json.load(f)

            # Get the product of the appropriate automata
            result = union([self.automata1[i], self.automata2[i]])

            # Print
            # helper.pretty_print(result)
            # helper.pretty_print(ans)

            # Check answer, making sure it's OK if elements not in order
            self.assertEqual(converter.convert_to_sets(result),
                             converter.convert_to_sets(ans))