summaryrefslogtreecommitdiffstats
path: root/googlemock/test
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-11-16 13:03:03 -0500
committerGennadiy Civil <misterg@google.com>2018-11-20 13:29:40 -0500
commit5dab7be70d628ad8079f915ab5bd3753dea1af2b (patch)
tree9ca927326d6357c7f5b9e9494bdf6d5ec29298c8 /googlemock/test
parent45d66d81bec9edd1256b6edb7e519602b1d0d6de (diff)
downloadgoogletest-5dab7be70d628ad8079f915ab5bd3753dea1af2b.tar.gz
googletest-5dab7be70d628ad8079f915ab5bd3753dea1af2b.zip
Googletest export
Validate spec modifiers. PiperOrigin-RevId: 221810235
Diffstat (limited to 'googlemock/test')
-rw-r--r--googlemock/test/gmock-function-mocker_nc.cc16
-rw-r--r--googlemock/test/gmock-function-mocker_nc_test.py43
2 files changed, 59 insertions, 0 deletions
diff --git a/googlemock/test/gmock-function-mocker_nc.cc b/googlemock/test/gmock-function-mocker_nc.cc
new file mode 100644
index 00000000..d38fe85e
--- /dev/null
+++ b/googlemock/test/gmock-function-mocker_nc.cc
@@ -0,0 +1,16 @@
+#include "gmock/gmock.h"
+
+#include <memory>
+#include <string>
+
+#if defined(TEST_MOCK_METHOD_INVALID_CONST_SPEC)
+
+struct Base {
+ MOCK_METHOD(int, F, (), (onst));
+};
+
+#else
+
+// Sanity check - this should compile.
+
+#endif
diff --git a/googlemock/test/gmock-function-mocker_nc_test.py b/googlemock/test/gmock-function-mocker_nc_test.py
new file mode 100644
index 00000000..8ef6e09f
--- /dev/null
+++ b/googlemock/test/gmock-function-mocker_nc_test.py
@@ -0,0 +1,43 @@
+"""Negative compilation tests for Google Mock macro MOCK_METHOD."""
+
+import os
+import sys
+
+IS_LINUX = os.name == "posix" and os.uname()[0] == "Linux"
+if not IS_LINUX:
+ sys.stderr.write(
+ "WARNING: Negative compilation tests are not supported on this platform")
+ sys.exit(0)
+
+# Suppresses the 'Import not at the top of the file' lint complaint.
+# pylint: disable-msg=C6204
+from google3.testing.pybase import fake_target_util
+from google3.testing.pybase import googletest
+
+# pylint: enable-msg=C6204
+
+
+class GMockMethodNCTest(googletest.TestCase):
+ """Negative compilation tests for MOCK_METHOD."""
+
+ # The class body is intentionally empty. The actual test*() methods
+ # will be defined at run time by a call to
+ # DefineNegativeCompilationTests() later.
+ pass
+
+
+# Defines a list of test specs, where each element is a tuple
+# (test name, list of regexes for matching the compiler errors).
+TEST_SPECS = [
+ ("MOCK_METHOD_INVALID_CONST_SPEC",
+ [r"onst cannot be recognized as a valid specification modifier"]),
+]
+
+# Define a test method in GMockNCTest for each element in TEST_SPECS.
+fake_target_util.DefineNegativeCompilationTests(
+ GMockMethodNCTest,
+ "google3/third_party/googletest/googlemock/test/gmock-function-mocker_nc",
+ "gmock-function-mocker_nc.o", TEST_SPECS)
+
+if __name__ == "__main__":
+ googletest.main()
OpenPOWER on IntegriCloud