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

Method testLegalCopyright

cpplint_unittest.py:5850–5883  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5848 self.TestLintLogCodeOnError(storage_class + " " + " ".join(other_decl_specs), "")
5849
5850 def testLegalCopyright(self):
5851 legal_copyright_message = (
5852 "No copyright message found. "
5853 'You should have a line: "Copyright [year] <Copyright Owner>"'
5854 " [legal/copyright] [5]"
5855 )
5856
5857 copyright_line = "// Copyright 2014 Google Inc. All Rights Reserved."
5858
5859 file_path = "mydir/googleclient/foo.cc"
5860
5861 # There should be a copyright message in the first 10 lines
5862 error_collector = ErrorCollector(self.assertTrue)
5863 cpplint.ProcessFileData(file_path, "cc", [], error_collector)
5864 assert error_collector.ResultList().count(legal_copyright_message) == 1
5865
5866 error_collector = ErrorCollector(self.assertTrue)
5867 cpplint.ProcessFileData(
5868 file_path, "cc", ["" for unused_i in range(10)] + [copyright_line], error_collector
5869 )
5870 assert error_collector.ResultList().count(legal_copyright_message) == 1
5871
5872 # Test that warning isn't issued if Copyright line appears early enough.
5873 error_collector = ErrorCollector(self.assertTrue)
5874 cpplint.ProcessFileData(file_path, "cc", [copyright_line], error_collector)
5875 for line in error_collector.ResultList():
5876 assert "legal/copyright" not in line
5877
5878 error_collector = ErrorCollector(self.assertTrue)
5879 cpplint.ProcessFileData(
5880 file_path, "cc", ["" for unused_i in range(9)] + [copyright_line], error_collector
5881 )
5882 for line in error_collector.ResultList():
5883 assert "legal/copyright" not in line
5884
5885 def testInvalidIncrement(self):
5886 self.TestLint(

Callers

nothing calls this directly

Calls 2

ResultListMethod · 0.95
ErrorCollectorClass · 0.85

Tested by

no test coverage detected