예제 #1
0
class CFormatCheckTest(CheckTestCase):
    check = CFormatCheck()
    flag = 'c-format'

    def setUp(self):
        super(CFormatCheckTest, self).setUp()
        self.test_highlight = (
            self.flag,
            '%sstring%d',
            [(0, 2, u'%s'), (8, 10, u'%d')],
        )

    def test_no_format(self):
        self.assertFalse(self.check.check_format('strins', 'string', False))

    def test_format(self):
        self.assertFalse(
            self.check.check_format('%s string', '%s string', False))

    def test_named_format(self):
        self.assertFalse(
            self.check.check_format('%10s string', '%10s string', False))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format('%s string', 'string', False))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format('%10s string', 'string',
                                                False))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format('%10s string', 'string',
                                                 True))

    def test_wrong_format(self):
        self.assertTrue(
            self.check.check_format('%s string', '%c string', False))

    def test_wrong_named_format(self):
        self.assertTrue(
            self.check.check_format('%10s string', '%20s string', False))

    def test_reorder_format(self):
        self.assertFalse(
            self.check.check_format('%1$s %2$s string', '%2$s %1$s string',
                                    False))

    def test_locale_delimiter(self):
        self.assertFalse(
            self.check.check_format('lines: %6.3f', 'radky: %\'6.3f', False))

    def test_ld_format(self):
        self.assertFalse(
            self.check.check_format(
                '%ld bytes (free %ld bytes, used %ld bytes)',
                '%l octets (%l octets libres, %l octets utilisés)', True))

    def test_parenthesis(self):
        self.assertFalse(
            self.check.check_format('(%.0lf%%)', '(%%%.0lf)', False))
예제 #2
0
class CFormatCheckTest(CheckTestCase):
    check = CFormatCheck()

    def setUp(self):
        super(CFormatCheckTest, self).setUp()
        self.test_highlight = (
            'c-format',
            '%sstring%d',
            [(0, 2, u'%s'), (8, 10, u'%d')],
        )

    def test_no_format(self):
        self.assertFalse(self.check.check_format('strins', 'string', False))

    def test_format(self):
        self.assertFalse(
            self.check.check_format('%s string', '%s string', False))

    def test_named_format(self):
        self.assertFalse(
            self.check.check_format('%10s string', '%10s string', False))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format('%s string', 'string', False))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format('%10s string', 'string',
                                                False))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format('%10s string', 'string',
                                                 True))

    def test_wrong_format(self):
        self.assertTrue(
            self.check.check_format('%s string', '%c string', False))

    def test_wrong_named_format(self):
        self.assertTrue(
            self.check.check_format('%10s string', '%20s string', False))

    def test_reorder_format(self):
        self.assertFalse(
            self.check.check_format('%1$s %2$s string', '%2$s %1$s string',
                                    False))

    def test_locale_delimiter(self):
        self.assertFalse(
            self.check.check_format('lines: %6.3f', 'radky: %\'6.3f', False))
예제 #3
0
class CFormatCheckTest(TestCase):
    def setUp(self):
        self.check = CFormatCheck()

    def test_no_format(self):
        self.assertFalse(
            self.check.check_format('strins', 'string',
                                    MockUnit('c_no_format'), 0, False))

    def test_format(self):
        self.assertFalse(
            self.check.check_format(u'%s string', u'%s string',
                                    MockUnit('c_format'), 0, False))

    def test_named_format(self):
        self.assertFalse(
            self.check.check_format(u'%10s string', u'%10s string',
                                    MockUnit('c_named_format'), 0, False))

    def test_missing_format(self):
        self.assertTrue(
            self.check.check_format(u'%s string', u'string',
                                    MockUnit('c_missing_format'), 0, False))

    def test_missing_named_format(self):
        self.assertTrue(
            self.check.check_format(u'%10s string', u'string',
                                    MockUnit('c_missing_named_format'), 0,
                                    False))

    def test_missing_named_format_ignore(self):
        self.assertFalse(
            self.check.check_format(u'%10s string', u'string',
                                    MockUnit('c_missing_named_format'), 0,
                                    True))

    def test_wrong_format(self):
        self.assertTrue(
            self.check.check_format(u'%s string', u'%c string',
                                    MockUnit('c_wrong_format'), 0, False))

    def test_wrong_named_format(self):
        self.assertTrue(
            self.check.check_format(u'%10s string', u'%20s string',
                                    MockUnit('c_wrong_named_format'), 0,
                                    False))
예제 #4
0
 def setUp(self):
     self.check = CFormatCheck()
예제 #5
0
class CFormatCheckTest(TestCase):
    def setUp(self):
        self.check = CFormatCheck()

    def test_no_format(self):
        self.assertFalse(self.check.check_format(
            'strins',
            'string',
            MockUnit('c_no_format'),
            0,
            False
        ))

    def test_format(self):
        self.assertFalse(self.check.check_format(
            u'%s string',
            u'%s string',
            MockUnit('c_format'),
            0,
            False
        ))

    def test_named_format(self):
        self.assertFalse(self.check.check_format(
            u'%10s string',
            u'%10s string',
            MockUnit('c_named_format'),
            0,
            False
        ))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'string',
            MockUnit('c_missing_format'),
            0,
            False
        ))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%10s string',
            u'string',
            MockUnit('c_missing_named_format'),
            0,
            False
        ))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format(
            u'%10s string',
            u'string',
            MockUnit('c_missing_named_format'),
            0,
            True
        ))

    def test_wrong_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'%c string',
            MockUnit('c_wrong_format'),
            0,
            False
        ))

    def test_wrong_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%10s string',
            u'%20s string',
            MockUnit('c_wrong_named_format'),
            0,
            False
        ))

    def test_reorder_format(self):
        self.assertFalse(self.check.check_format(
            u'%1$s %2$s string',
            u'%2$s %1$s string',
            MockUnit('c_reorder_format'),
            0,
            False
        ))
예제 #6
0
class CFormatCheckTest(TestCase):
    def setUp(self):
        self.check = CFormatCheck()

    def test_no_format(self):
        self.assertFalse(self.check.check_format(
            'strins',
            'string',
            False
        ))

    def test_format(self):
        self.assertFalse(self.check.check_format(
            '%s string',
            '%s string',
            False
        ))

    def test_named_format(self):
        self.assertFalse(self.check.check_format(
            '%10s string',
            '%10s string',
            False
        ))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format(
            '%s string',
            'string',
            False
        ))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format(
            '%10s string',
            'string',
            False
        ))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format(
            '%10s string',
            'string',
            True
        ))

    def test_wrong_format(self):
        self.assertTrue(self.check.check_format(
            '%s string',
            '%c string',
            False
        ))

    def test_wrong_named_format(self):
        self.assertTrue(self.check.check_format(
            '%10s string',
            '%20s string',
            False
        ))

    def test_reorder_format(self):
        self.assertFalse(self.check.check_format(
            '%1$s %2$s string',
            '%2$s %1$s string',
            False
        ))

    def test_locale_delimiter(self):
        self.assertFalse(self.check.check_format(
            'lines: %6.3f',
            'radky: %\'6.3f',
            False
        ))
예제 #7
0
 def setUp(self):
     self.check = CFormatCheck()
예제 #8
0
class CFormatCheckTest(TestCase):
    def setUp(self):
        self.check = CFormatCheck()

    def test_no_format(self):
        self.assertFalse(self.check.check_format(
            'strins',
            'string',
            MockUnit('c_no_format'),
            0,
            False
        ))

    def test_format(self):
        self.assertFalse(self.check.check_format(
            u'%s string',
            u'%s string',
            MockUnit('c_format'),
            0,
            False
        ))

    def test_named_format(self):
        self.assertFalse(self.check.check_format(
            u'%10s string',
            u'%10s string',
            MockUnit('c_named_format'),
            0,
            False
        ))

    def test_missing_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'string',
            MockUnit('c_missing_format'),
            0,
            False
        ))

    def test_missing_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%10s string',
            u'string',
            MockUnit('c_missing_named_format'),
            0,
            False
        ))

    def test_missing_named_format_ignore(self):
        self.assertFalse(self.check.check_format(
            u'%10s string',
            u'string',
            MockUnit('c_missing_named_format'),
            0,
            True
        ))

    def test_wrong_format(self):
        self.assertTrue(self.check.check_format(
            u'%s string',
            u'%c string',
            MockUnit('c_wrong_format'),
            0,
            False
        ))

    def test_wrong_named_format(self):
        self.assertTrue(self.check.check_format(
            u'%10s string',
            u'%20s string',
            MockUnit('c_wrong_named_format'),
            0,
            False
        ))

    def test_reorder_format(self):
        self.assertFalse(self.check.check_format(
            u'%1$s %2$s string',
            u'%2$s %1$s string',
            MockUnit('c_reorder_format'),
            0,
            False
        ))

    def test_locale_delimiter(self):
        self.assertFalse(self.check.check_format(
            u'lines: %6.3f',
            u'radky: %\'6.3f',
            MockUnit('c_locale_delimiter'),
            0,
            False
        ))