| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Tests for enum_preprocess.py. | 6 """Tests for enum_preprocess.py. |
| 7 | 7 |
| 8 This test suite containss various tests for the C++ -> Java enum generator. | 8 This test suite containss various tests for the C++ -> Java enum generator. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 def testParseMalformedMultiLineDirectiveShort(self): | 402 def testParseMalformedMultiLineDirectiveShort(self): |
| 403 test_data = """ | 403 test_data = """ |
| 404 // GENERATED_JAVA_ENUM_PACKAGE: ( | 404 // GENERATED_JAVA_ENUM_PACKAGE: ( |
| 405 enum Foo { | 405 enum Foo { |
| 406 FOO_A, | 406 FOO_A, |
| 407 }; | 407 }; |
| 408 """.split('\n') | 408 """.split('\n') |
| 409 with self.assertRaises(Exception): | 409 with self.assertRaises(Exception): |
| 410 HeaderParser(test_data).ParseDefinitions() | 410 HeaderParser(test_data).ParseDefinitions() |
| 411 | 411 |
| 412 def testParseMalformedMultiLineDirectiveMissingBrackets(self): |
| 413 test_data = """ |
| 414 // GENERATED_JAVA_ENUM_PACKAGE: |
| 415 // test.namespace |
| 416 enum Foo { |
| 417 FOO_A, |
| 418 }; |
| 419 """.split('\n') |
| 420 with self.assertRaises(Exception): |
| 421 HeaderParser(test_data).ParseDefinitions() |
| 422 |
| 412 def testEnumValueAssignmentNoneDefined(self): | 423 def testEnumValueAssignmentNoneDefined(self): |
| 413 definition = EnumDefinition(original_enum_name='c', enum_package='p') | 424 definition = EnumDefinition(original_enum_name='c', enum_package='p') |
| 414 definition.AppendEntry('A', None) | 425 definition.AppendEntry('A', None) |
| 415 definition.AppendEntry('B', None) | 426 definition.AppendEntry('B', None) |
| 416 definition.AppendEntry('C', None) | 427 definition.AppendEntry('C', None) |
| 417 definition.Finalize() | 428 definition.Finalize() |
| 418 self.assertEqual(collections.OrderedDict([('A', 0), | 429 self.assertEqual(collections.OrderedDict([('A', 0), |
| 419 ('B', 1), | 430 ('B', 1), |
| 420 ('C', 2)]), | 431 ('C', 2)]), |
| 421 definition.entries) | 432 definition.entries) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 options, _ = parser.parse_args(argv) | 540 options, _ = parser.parse_args(argv) |
| 530 | 541 |
| 531 suite = unittest.TestLoader().loadTestsFromTestCase(TestPreprocess) | 542 suite = unittest.TestLoader().loadTestsFromTestCase(TestPreprocess) |
| 532 unittest.TextTestRunner(verbosity=0).run(suite) | 543 unittest.TextTestRunner(verbosity=0).run(suite) |
| 533 | 544 |
| 534 if options.stamp: | 545 if options.stamp: |
| 535 build_utils.Touch(options.stamp) | 546 build_utils.Touch(options.stamp) |
| 536 | 547 |
| 537 if __name__ == '__main__': | 548 if __name__ == '__main__': |
| 538 main(sys.argv[1:]) | 549 main(sys.argv[1:]) |
| OLD | NEW |