Index: build/android/gyp/java_cpp_enum_tests.py |
diff --git a/build/android/gyp/java_cpp_enum_tests.py b/build/android/gyp/java_cpp_enum_tests.py |
index 75e6671ed1616f4601dc07090f9ac7d60609f683..44f9766c82c98d6c6bab67764d89ee4bc6640282 100755 |
--- a/build/android/gyp/java_cpp_enum_tests.py |
+++ b/build/android/gyp/java_cpp_enum_tests.py |
@@ -14,6 +14,7 @@ import os |
import sys |
import unittest |
+import java_cpp_enum |
from java_cpp_enum import EnumDefinition, GenerateOutput, GetScriptName |
from java_cpp_enum import HeaderParser |
@@ -151,6 +152,14 @@ public class ClassName { |
with self.assertRaises(Exception): |
HeaderParser(test_data).ParseDefinitions() |
+ def testParseReturnsEmptyListWithoutDirectives(self): |
+ test_data = """ |
+ enum EnumName { |
+ VALUE_ONE, |
+ }; |
+ """.split('\n') |
+ self.assertEqual([], HeaderParser(test_data).ParseDefinitions()) |
+ |
def testParseEnumClass(self): |
test_data = """ |
// GENERATED_JAVA_ENUM_PACKAGE: test.namespace |
@@ -403,6 +412,15 @@ public class ClassName { |
definition.Finalize() |
self.assertEqual(['A', 'B', 'NAME_LAST'], definition.entries.keys()) |
+ def testGenerateThrowsOnEmptyInput(self): |
+ with self.assertRaises(Exception): |
+ original_do_parse = java_cpp_enum.DoParseHeaderFile |
+ try: |
+ java_cpp_enum.DoParseHeaderFile = lambda _: [] |
+ java_cpp_enum.DoGenerate('dir', ['file']) |
+ finally: |
+ java_cpp_enum.DoParseHeaderFile = original_do_parse |
+ |
def main(argv): |
parser = optparse.OptionParser() |
parser.add_option("--stamp", help="File to touch on success.") |