class JavaFormatCheckTest(CheckTestCase): check = JavaFormatCheck() def setUp(self): super().setUp() self.test_highlight = ( "java-format", "%1s string %2s", [(0, 3, "%1s"), (11, 14, "%2s")], ) def test_no_format(self): self.assertFalse(self.check.check_format("strins", "string", False, None)) def test_escaping(self): self.assertFalse(self.check.check_format("%% s %%", "string", False, None)) def test_format(self): self.assertFalse(self.check.check_format("%s string", "%s string", False, None)) def test_time_format(self): self.assertFalse( self.check.check_format("%1$tH strins", "%1$tH string", False, None) ) def test_wrong_position_format(self): self.assertTrue( self.check.check_format("%s string", "%s string %s", False, None) ) def test_named_format(self): self.assertFalse( self.check.check_format("%1s string %2s", "%1s string %2s", False, None) ) def test_missing_format(self): self.assertTrue(self.check.check_format("%1s string", "string", False, None)) def test_missing_named_format(self): self.assertTrue(self.check.check_format("%1$05d string", "string", False, None)) def test_wrong_argument_format(self): self.assertTrue( self.check.check_format("%1s string", "%2s string", False, None) ) def test_wrong_format(self): self.assertTrue(self.check.check_format("%s strins", "%d string", False, None)) def test_missing_named_format_ignore(self): self.assertFalse(self.check.check_format("%1s string", "string", True, None)) def test_reordered_format(self): self.assertTrue( self.check.check_format("%1s string %2d", "%2d string %1s", False, None) )
class JavaFormatCheckTest(CheckTestCase): check = JavaFormatCheck() def setUp(self): super(JavaFormatCheckTest, self).setUp() self.test_highlight = ( 'java-format', '%1s string %2s', [(0, 3, u'%1s'), (11, 14, u'%2s')], ) def test_no_format(self): self.assertFalse(self.check.check_format('strins', 'string', False)) def test_escaping(self): self.assertFalse(self.check.check_format('%% s %%', 'string', False)) def test_format(self): self.assertFalse( self.check.check_format('%s string', '%s string', False)) def test_time_format(self): self.assertFalse( self.check.check_format('%1$tH strins', '%1$tH string', False)) def test_wrong_position_format(self): self.assertTrue( self.check.check_format('%s string', '%s string %s', False)) def test_named_format(self): self.assertFalse( self.check.check_format('%1s string %2s', '%1s string %2s', False)) def test_missing_format(self): self.assertTrue(self.check.check_format('%1s string', 'string', False)) def test_missing_named_format(self): self.assertTrue( self.check.check_format('%1$05d string', 'string', False)) def test_wrong_argument_format(self): self.assertTrue( self.check.check_format('%1s string', '%2s string', False)) def test_wrong_format(self): self.assertTrue( self.check.check_format('%s strins', '%d string', False)) def test_missing_named_format_ignore(self): self.assertFalse(self.check.check_format('%1s string', 'string', True)) def test_reordered_format(self): self.assertTrue( self.check.check_format('%1s string %2d', '%2d string %1s', False))