@Test public void testHasIntersectionWithSingleLineComment() { final FileContents fileContents = new FileContents( new FileText(new File("filename"), Arrays.asList(" ", " //test ", " //test ", " //test "))); fileContents.reportCppComment(4, 4); assertTrue("Should return true when comments intersect", fileContents.hasIntersectionWithComment(1, 3, 4, 6)); }
@Test public void testReportCppComment() { final FileContents fileContents = new FileContents( new FileText(new File("filename"), Collections.singletonList(" // "))); fileContents.reportCppComment(1, 2); final Map<Integer, TextBlock> cppComments = fileContents.getCppComments(); assertEquals("Invalid comment", new Comment(new String[] {" // "}, 2, 1, 6).toString(), cppComments.get(1).toString()); }
@Test public void testDeprecatedAbbreviatedMethod() { // just to make UT coverage 100% final FileContents fileContents = new FileContents("filename", "123", "456"); fileContents.reportCppComment(1, 1); fileContents.reportCComment(1, 1, 1, 1); final Comment cppComment = new Comment(new String[] {"23"}, 1, 1, 2); final Comment cComment = new Comment(new String[] {"2"}, 1, 1, 1); assertEquals("Invalid cpp comment", cppComment.toString(), fileContents.getCppComments().get(1).toString()); assertEquals("Invalid c comment", cComment.toString(), fileContents.getCComments().get(1).get(0).toString()); }