You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.3 KiB

  1. """Negative compilation tests for Google Mock macro MOCK_METHOD."""
  2. import os
  3. import sys
  4. IS_LINUX = os.name == "posix" and os.uname()[0] == "Linux"
  5. if not IS_LINUX:
  6. sys.stderr.write(
  7. "WARNING: Negative compilation tests are not supported on this platform")
  8. sys.exit(0)
  9. # Suppresses the 'Import not at the top of the file' lint complaint.
  10. # pylint: disable-msg=C6204
  11. from google3.testing.pybase import fake_target_util
  12. from google3.testing.pybase import googletest
  13. # pylint: enable-msg=C6204
  14. class GMockMethodNCTest(googletest.TestCase):
  15. """Negative compilation tests for MOCK_METHOD."""
  16. # The class body is intentionally empty. The actual test*() methods
  17. # will be defined at run time by a call to
  18. # DefineNegativeCompilationTests() later.
  19. pass
  20. # Defines a list of test specs, where each element is a tuple
  21. # (test name, list of regexes for matching the compiler errors).
  22. TEST_SPECS = [
  23. ("MOCK_METHOD_INVALID_CONST_SPEC",
  24. [r"onst cannot be recognized as a valid specification modifier"]),
  25. ]
  26. # Define a test method in GMockNCTest for each element in TEST_SPECS.
  27. fake_target_util.DefineNegativeCompilationTests(
  28. GMockMethodNCTest,
  29. "google3/third_party/googletest/googlemock/test/gmock-function-mocker_nc",
  30. "gmock-function-mocker_nc.o", TEST_SPECS)
  31. if __name__ == "__main__":
  32. googletest.main()