MCPcopy Index your code
hub / github.com/cpplint/cpplint / testMockMethod

Method testMockMethod

cpplint_unittest.py:1072–1109  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1070 # The second parameter to a gMock method definition is a function signature
1071 # that often looks like a bad cast but should not picked up by lint.
1072 def testMockMethod(self):
1073 self.TestLint("MOCK_METHOD0(method, int());", "")
1074 self.TestLint("MOCK_CONST_METHOD1(method, float(string));", "")
1075 self.TestLint("MOCK_CONST_METHOD2_T(method, double(float, float));", "")
1076 self.TestLint("MOCK_CONST_METHOD1(method, SomeType(int));", "")
1077
1078 error_collector = ErrorCollector(self.assertTrue)
1079 cpplint.ProcessFileData(
1080 "mock.cc",
1081 "cc",
1082 [
1083 "MOCK_METHOD1(method1,",
1084 " bool(int));",
1085 "MOCK_METHOD1(",
1086 " method2,",
1087 " bool(int));",
1088 "MOCK_CONST_METHOD2(",
1089 " method3, bool(int,",
1090 " int));",
1091 "MOCK_METHOD1(method4, int(bool));",
1092 "const int kConstant = int(42);",
1093 ], # true positive
1094 error_collector,
1095 )
1096 assert (
1097 error_collector.Results().count(
1098 "Using deprecated casting style. Use static_cast<bool>(...) instead "
1099 "[readability/casting] [4]"
1100 )
1101 == 0
1102 )
1103 assert (
1104 error_collector.Results().count(
1105 "Using deprecated casting style. Use static_cast<int>(...) instead "
1106 "[readability/casting] [4]"
1107 )
1108 == 1
1109 )
1110
1111 # Like gMock method definitions, MockCallback instantiations look very similar
1112 # to bad casts.

Callers

nothing calls this directly

Calls 3

ResultsMethod · 0.95
ErrorCollectorClass · 0.85
TestLintMethod · 0.80

Tested by

no test coverage detected