Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

Issue 2800883004: Port cpplint's C++11 raw string support to blink's cpp style checker. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- coding: utf-8; -*- 1 # -*- coding: utf-8; -*-
2 # 2 #
3 # Copyright (C) 2011 Google Inc. All rights reserved. 3 # Copyright (C) 2011 Google Inc. All rights reserved.
4 # Copyright (C) 2009 Torch Mobile Inc. 4 # Copyright (C) 2009 Torch Mobile Inc.
5 # Copyright (C) 2009 Apple Inc. All rights reserved. 5 # Copyright (C) 2009 Apple Inc. All rights reserved.
6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org)
7 # 7 #
8 # Redistribution and use in source and binary forms, with or without 8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are 9 # modification, are permitted provided that the following conditions are
10 # met: 10 # met:
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 cpp_style.cleanse_comments('int /* foo */ o = 0;')) 1085 cpp_style.cleanse_comments('int /* foo */ o = 0;'))
1086 self.assertEqual('foo(int a, int b);', 1086 self.assertEqual('foo(int a, int b);',
1087 cpp_style.cleanse_comments('foo(int a /* abc */, int b) ;')) 1087 cpp_style.cleanse_comments('foo(int a /* abc */, int b) ;'))
1088 self.assertEqual('f(a, b);', 1088 self.assertEqual('f(a, b);',
1089 cpp_style.cleanse_comments('f(a, /* name */ b);')) 1089 cpp_style.cleanse_comments('f(a, /* name */ b);'))
1090 self.assertEqual('f(a, b);', 1090 self.assertEqual('f(a, b);',
1091 cpp_style.cleanse_comments('f(a /* name */, b);')) 1091 cpp_style.cleanse_comments('f(a /* name */, b);'))
1092 self.assertEqual('f(a, b);', 1092 self.assertEqual('f(a, b);',
1093 cpp_style.cleanse_comments('f(a, /* name */b);')) 1093 cpp_style.cleanse_comments('f(a, /* name */b);'))
1094 1094
1095 def test_raw_strings(self):
1096 self.assert_multi_line_lint(
1097 '''
1098 void Func() {
1099 static const char kString[] = R"(
1100 #endif <- invalid preprocessor should be ignored
1101 */ <- invalid comment should be ignored too
1102 )";
1103 }''',
1104 '')
1105 self.assert_multi_line_lint(
1106 '''
1107 void Func() {
1108 const char s[] = R"TrueDelimiter(
1109 )"
1110 )FalseDelimiter"
1111 )TrueDelimiter";
1112 }''',
1113 '')
1114 self.assert_multi_line_lint(
1115 '''
1116 void Func() {
1117 char char kString[] = R"( ";" )";
1118 }''',
1119 '')
1120 self.assert_multi_line_lint(
1121 '''
1122 static const char kRawString[] = R"(
1123 \tstatic const int kLineWithTab = 1;
1124 static const int kLineWithTrailingWhiteSpace = 1;\x20
1125
1126 void WeirdNumberOfSpacesAtLineStart() {
1127 string x;
1128 x += StrCat("Use StrAppend instead");
1129 }
1130
1131 void BlankLineAtEndOfBlock() {
1132 // TODO incorrectly formatted
1133 //Badly formatted comment
1134
1135 }
1136
1137 )";''',
1138 '')
1139
1095 def test_multi_line_comments(self): 1140 def test_multi_line_comments(self):
1096 # missing explicit is bad 1141 # missing explicit is bad
1097 self.assert_multi_line_lint( 1142 self.assert_multi_line_lint(
1098 r'''int a = 0; 1143 r'''int a = 0;
1099 /* multi-liner 1144 /* multi-liner
1100 class Foo { 1145 class Foo {
1101 Foo(int f); // should cause a lint warning in code 1146 Foo(int f); // should cause a lint warning in code
1102 } 1147 }
1103 */ ''', 1148 */ ''',
1104 '') 1149 '')
(...skipping 2864 matching lines...) Expand 10 before | Expand all | Expand 10 after
3969 def test_ne(self): 4014 def test_ne(self):
3970 """Test __ne__ inequality function.""" 4015 """Test __ne__ inequality function."""
3971 checker1 = self._checker() 4016 checker1 = self._checker()
3972 checker2 = self._checker() 4017 checker2 = self._checker()
3973 4018
3974 # != calls __ne__. 4019 # != calls __ne__.
3975 # By default, __ne__ always returns true on different objects. 4020 # By default, __ne__ always returns true on different objects.
3976 # Thus, just check the distinguishing case to verify that the 4021 # Thus, just check the distinguishing case to verify that the
3977 # code defines __ne__. 4022 # code defines __ne__.
3978 self.assertFalse(checker1 != checker2) 4023 self.assertFalse(checker1 != checker2)
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698