]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1836 Add tests against bugs in Checkstyle
authorEvgeny Mandrikov <mandrikov@gmail.com>
Wed, 21 Sep 2011 23:27:03 +0000 (03:27 +0400)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Thu, 22 Sep 2011 09:11:58 +0000 (13:11 +0400)
Those tests will allow us to be notified during update of Checkstyle
that bugs were fixed :
* escaped unicode (exists in Checkstyle 5.1 - 5.4)
* line comment at the end of file (exists in Checkstyle 5.2 - 5.4)

plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/JavaAstScannerTest.java
plugins/sonar-squid-java-plugin/test-resources/special_cases/parsingErrors/LineCommentAtTheEndOfFile.java [new file with mode: 0644]
plugins/sonar-squid-java-plugin/test-resources/special_cases/parsingErrors/UnicodeEscape.java [new file with mode: 0644]

index afddc3cf2cd8bd8993f5a33f13d536960a8f222c..12f38e5cfccc0c78f41e50e2467e48fe5ced3345 100644 (file)
@@ -67,6 +67,26 @@ public class JavaAstScannerTest {
     assertEquals(0, prj.getInt(Metric.CLASSES));
   }
 
+  /**
+   * SONAR-1908
+   */
+  @Test(expected = AnalysisException.class)
+  public void testUnicodeEscape() {
+    // see
+    // https://sourceforge.net/tracker/?func=detail&aid=3296452&group_id=29721&atid=397078
+    squid.register(JavaAstScanner.class).scanFile(SquidTestUtils.getInputFile("/special_cases/parsingErrors/UnicodeEscape.java"));
+  }
+
+  /**
+   * SONAR-1836: bug in Checkstyle 5.2 - 5.4
+   */
+  @Test
+  public void testLineCommentAtTheEndOfFile() {
+    squid.register(JavaAstScanner.class).scanFile(SquidTestUtils.getInputFile("/special_cases/parsingErrors/LineCommentAtTheEndOfFile.java"));
+    SourceProject prj = squid.aggregate();
+    assertEquals(1, prj.getInt(Metric.CLASSES));
+  }
+
   @Test
   public void testEmptyClassWithComment() {
     squid.register(JavaAstScanner.class).scanFile(SquidTestUtils.getInputFile("/special_cases/emptyFiles/ClassWithOnlyComment.java"));
diff --git a/plugins/sonar-squid-java-plugin/test-resources/special_cases/parsingErrors/LineCommentAtTheEndOfFile.java b/plugins/sonar-squid-java-plugin/test-resources/special_cases/parsingErrors/LineCommentAtTheEndOfFile.java
new file mode 100644 (file)
index 0000000..a9b8769
--- /dev/null
@@ -0,0 +1,3 @@
+public class LineCommentAtTheEndOfFile
+{
+} // EOF on this line
\ No newline at end of file
diff --git a/plugins/sonar-squid-java-plugin/test-resources/special_cases/parsingErrors/UnicodeEscape.java b/plugins/sonar-squid-java-plugin/test-resources/special_cases/parsingErrors/UnicodeEscape.java
new file mode 100644 (file)
index 0000000..38ea3a8
--- /dev/null
@@ -0,0 +1,9 @@
+public class UnicodeEscape {
+
+  public void foo() {
+    char a = '\u005Cr';
+    char b = '\uuuu005Cr';
+    char c = '\u005c\u005c';
+  }
+
+}