def test_conversion(self):
        with self.assertRaises(TypeError):
            ClangCountingConditions.counting_condition(5)

        self.assertEqual(
            ClangCountingConditions.counting_condition(Setting("irrelevant", "used, in_condition")),
            [ClangCountingConditions.used, ClangCountingConditions.in_condition],
        )
    def test_conversion(self):
        with self.assertRaises(TypeError):
            ClangCountingConditions.counting_condition(5)

        self.assertEqual(
            ClangCountingConditions.counting_condition(
                Setting("irrelevant", "used, in_condition")),
            [ClangCountingConditions.used,
             ClangCountingConditions.in_condition])
    def check_counting_condition(self, conditions, function, expected):
        """
        Checks if the given count vectors match the given expected data.

        :param conditions: String indicating which condition(s) to use (will
                           be fed to
                           ClangCountingConditions.counting_condition)
        :param function:   String indicating which function from test file to
                           use. (i.e. "used(int, int)")
        :param expected:   Dict with python lists of counts for all variables.
        """
        counter = ClangCountVectorCreator(
            ClangCountingConditions.counting_condition(
                Setting("irrelevant", conditions)))
        vectors = counter.get_vectors_for_file(self.testfile)

        actual = vectors[function]
        self.assertEqual(len(actual),
                         len(expected),
                         "Actual dict: " + str(actual))
        self.assertEqual(sorted(actual.keys()),
                         sorted(expected.keys()))
        for variable in actual:
            self.assertEqual(actual[variable].count_vector,
                             expected[variable],
                             "Variable '{}' doesnt match.".format(variable))
    def check_counting_condition(self, conditions, function, expected):
        """
        Checks if the given count vectors match the given expected data.

        :param conditions: String indicating which condition(s) to use (will
                           be fed to
                           ClangCountingConditions.counting_condition)
        :param function:   String indicating which function from test file to
                           use. (i.e. "used(int, int)")
        :param expected:   Dict with python lists of counts for all variables.
        """
        counter = ClangCountVectorCreator(
            ClangCountingConditions.counting_condition(
                Setting("irrelevant", conditions)))
        vectors = counter.get_vectors_for_file(self.testfile)

        actual = vectors[function]
        self.assertEqual(len(actual),
                         len(expected),
                         "Actual dict: " + str(actual))
        self.assertEqual(sorted(actual.keys()),
                         sorted(expected.keys()))
        for variable in actual:
            self.assertEqual(actual[variable].count_vector,
                             expected[variable],
                             "Variable '{}' doesnt match.".format(variable))