diff options
Diffstat (limited to 'tools/check-moz-style/tests')
-rw-r--r-- | tools/check-moz-style/tests/test1.cpp | 0 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test1.out | 1 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test1.patch | 1 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test2.cpp | 3 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test2.out | 4 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test2.patch | 9 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test3.out | 3 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test3.patch | 12 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test4.cpp | 40 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test4.out | 13 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test4.patch | 49 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test5.cpp | 24 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test5.out | 7 | ||||
-rw-r--r-- | tools/check-moz-style/tests/test5.patch | 33 |
14 files changed, 199 insertions, 0 deletions
diff --git a/tools/check-moz-style/tests/test1.cpp b/tools/check-moz-style/tests/test1.cpp new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tools/check-moz-style/tests/test1.cpp diff --git a/tools/check-moz-style/tests/test1.out b/tools/check-moz-style/tests/test1.out new file mode 100644 index 000000000..3c313c18a --- /dev/null +++ b/tools/check-moz-style/tests/test1.out @@ -0,0 +1 @@ +patch:0: Patch does not appear to diff against any file. [patch/notempty] [3] diff --git a/tools/check-moz-style/tests/test1.patch b/tools/check-moz-style/tests/test1.patch new file mode 100644 index 000000000..8c56b2416 --- /dev/null +++ b/tools/check-moz-style/tests/test1.patch @@ -0,0 +1 @@ +Bad patch that doesn't diff any files diff --git a/tools/check-moz-style/tests/test2.cpp b/tools/check-moz-style/tests/test2.cpp new file mode 100644 index 000000000..4cce7f667 --- /dev/null +++ b/tools/check-moz-style/tests/test2.cpp @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/tools/check-moz-style/tests/test2.out b/tools/check-moz-style/tests/test2.out new file mode 100644 index 000000000..0648d555e --- /dev/null +++ b/tools/check-moz-style/tests/test2.out @@ -0,0 +1,4 @@ +patch:0: Patch does not have a summary. [patch/nosummary] [3] +patch:0: Patch does not have a description. [patch/nodescription] [3] +tests/test2.cpp:1: No copyright message found. [legal/copyright] [3] +Done processing tests/test2.cpp diff --git a/tools/check-moz-style/tests/test2.patch b/tools/check-moz-style/tests/test2.patch new file mode 100644 index 000000000..e497ec0cf --- /dev/null +++ b/tools/check-moz-style/tests/test2.patch @@ -0,0 +1,9 @@ +# Test +diff --git a/tests/test2.cpp b/tests/test2.cpp +new file mode 100644 +--- /dev/null ++++ b/tests/test2.cpp +@@ -0,0 +1,3 @@ ++int main() { ++ return 0; ++} diff --git a/tools/check-moz-style/tests/test3.out b/tools/check-moz-style/tests/test3.out new file mode 100644 index 000000000..5a2cc7385 --- /dev/null +++ b/tools/check-moz-style/tests/test3.out @@ -0,0 +1,3 @@ +patch:0: Patch summary should begin with 'Bug XXXXX - ' or 'No bug -'. [patch/bugnumber] [3] +tests/test2.cpp:1: No copyright message found. [legal/copyright] [3] +Done processing tests/test2.cpp diff --git a/tools/check-moz-style/tests/test3.patch b/tools/check-moz-style/tests/test3.patch new file mode 100644 index 000000000..d0443fa52 --- /dev/null +++ b/tools/check-moz-style/tests/test3.patch @@ -0,0 +1,12 @@ +# Test +patch summary with no bug number + +Some bogus patch description +diff --git a/tests/test2.cpp b/tests/test2.cpp +new file mode 100644 +--- /dev/null ++++ b/tests/test2.cpp +@@ -0,0 +1,3 @@ ++int main() { ++ return 0; ++} diff --git a/tools/check-moz-style/tests/test4.cpp b/tools/check-moz-style/tests/test4.cpp new file mode 100644 index 000000000..64ceae0b6 --- /dev/null +++ b/tools/check-moz-style/tests/test4.cpp @@ -0,0 +1,40 @@ +class ShouldUseExplicit { + // runtime/explicit + ShouldUseExplicit(int i); +}; + +// readability/function +int foo(int) { +} + +int main() { + int i = 0; + + // readability/control_flow + // XXX This doesn't trigger it. It needs to be fixed. + if (i) { + return; + } else { + i++; + } + + // whitespace/parens + if(i){} + + // readability/casting + void* bad = (void*)i; + + // readability/comparison_to_zero + if (i == true) {} + if (i == false) {} + if (i != true) {} + if (i != false) {} + if (i == NULL) {} + if (i != NULL) {} + if (i == nullptr) {} + if (i != nullptr) {} + if (i) {} + if (!i) {} + + return 0; +} diff --git a/tools/check-moz-style/tests/test4.out b/tools/check-moz-style/tests/test4.out new file mode 100644 index 000000000..21eadcca1 --- /dev/null +++ b/tools/check-moz-style/tests/test4.out @@ -0,0 +1,13 @@ +tests/test4.cpp:1: No copyright message found. [legal/copyright] [3] +tests/test4.cpp:3: Single-argument constructors should be marked explicit. [runtime/explicit] [5] +tests/test4.cpp:7: All parameters should be named in a function [readability/function] [3] +tests/test4.cpp:22: Missing space before ( in if( [whitespace/parens] [5] +tests/test4.cpp:22: Missing space before { [whitespace/braces] [5] +tests/test4.cpp:25: Using C-style cast. Use reinterpret_cast<void*>(...) instead [readability/casting] [4] +tests/test4.cpp:28: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] +tests/test4.cpp:29: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] +tests/test4.cpp:30: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] +tests/test4.cpp:31: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] +tests/test4.cpp:32: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] +tests/test4.cpp:33: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] +Done processing tests/test4.cpp diff --git a/tools/check-moz-style/tests/test4.patch b/tools/check-moz-style/tests/test4.patch new file mode 100644 index 000000000..735ef82ca --- /dev/null +++ b/tools/check-moz-style/tests/test4.patch @@ -0,0 +1,49 @@ +# Test +Bug 12 - patch summary with no bug number + +Some bogus patch description +diff --git a/tests/test4.cpp b/tests/test4.cpp +new file mode 100644 +--- /dev/null ++++ b/tests/test4.cpp +@@ -0,0 +1,49 @@ ++class ShouldUseExplicit { ++ // runtime/explicit ++ ShouldUseExplicit(int i); ++}; ++ ++// readability/function ++int foo(int) { ++} ++ ++int main() { ++ int i = 0; ++ ++ // readability/control_flow ++ // XXX This doesn't trigger it. It needs to be fixed. ++ if (i) { ++ return; ++ } else { ++ i++; ++ } ++ ++ // whitespace/parens ++ if(i){} ++ ++ // readability/casting ++ void* bad = (void*)i; ++ ++ // readability/comparison_to_zero ++ if (i == true) {} ++ if (i == false) {} ++ if (i != true) {} ++ if (i != false) {} ++ if (i == NULL) {} ++ if (i != NULL) {} ++ if (i == nullptr) {} ++ if (i != nullptr) {} ++ if (i) {} ++ if (!i) {} ++ ++ return 0; ++} diff --git a/tools/check-moz-style/tests/test5.cpp b/tools/check-moz-style/tests/test5.cpp new file mode 100644 index 000000000..95c756151 --- /dev/null +++ b/tools/check-moz-style/tests/test5.cpp @@ -0,0 +1,24 @@ +// License bogus + +// runtime/virtual +class ShouldHaveVirtualDes { + virtual foo(); +}; + +int main() { + // runtime/memset + memset(blah, sizeof(blah), 0); + + // runtime/rtti + dynamic_cast<Derived*>(obj); + + // runtime/sizeof + int varname = 0; + int mySize = sizeof(int); + + // runtime/threadsafe_fn + getpwuid(); + strtok(); + + return 0; +} diff --git a/tools/check-moz-style/tests/test5.out b/tools/check-moz-style/tests/test5.out new file mode 100644 index 000000000..68c0eab8a --- /dev/null +++ b/tools/check-moz-style/tests/test5.out @@ -0,0 +1,7 @@ +tests/test5.cpp:4: The class ShouldHaveVirtualDes probably needs a virtual destructor due to having virtual method(s), one declared at line 5. [runtime/virtual] [4] +tests/test5.cpp:10: Did you mean "memset(blah, 0, sizeof(blah))"? [runtime/memset] [4] +tests/test5.cpp:13: Do not use dynamic_cast<>. If you need to cast within a class hierarchy, use static_cast<> to upcast. Mozilla doesn't support RTTI. [runtime/rtti] [5] +tests/test5.cpp:17: Using sizeof(type). Use sizeof(varname) instead if possible [runtime/sizeof] [1] +tests/test5.cpp:20: Consider using getpwuid_r(...) instead of getpwuid(...) for improved thread safety. [runtime/threadsafe_fn] [2] +tests/test5.cpp:21: Consider using strtok_r(...) instead of strtok(...) for improved thread safety. [runtime/threadsafe_fn] [2] +Done processing tests/test5.cpp diff --git a/tools/check-moz-style/tests/test5.patch b/tools/check-moz-style/tests/test5.patch new file mode 100644 index 000000000..19f7bee8c --- /dev/null +++ b/tools/check-moz-style/tests/test5.patch @@ -0,0 +1,33 @@ +# Test +Bug 12 - patch summary with no bug number + +Some bogus patch description +diff --git a/tests/test5.cpp b/tests/test5.cpp +new file mode 100644 +--- /dev/null ++++ b/tests/test5.cpp +@@ -0,0 +1,24 @@ ++// License bogus ++ ++// runtime/virtual ++class ShouldHaveVirtualDes { ++ virtual foo(); ++}; ++ ++int main() { ++ // runtime/memset ++ memset(blah, sizeof(blah), 0); ++ ++ // runtime/rtti ++ dynamic_cast<Derived*>(obj); ++ ++ // runtime/sizeof ++ int varname = 0; ++ int mySize = sizeof(int); ++ ++ // runtime/threadsafe_fn ++ getpwuid(); ++ strtok(); ++ ++ return 0; ++} |