CommentSkipHelper { public String skipComments(String line) { if (!inBlockComment && line.contains("")) { blockCommentBegin(); String lhs = line.substring(0, line.lastIndexOf("")) { line = lhs + line.substring(line.lastIndexOf("*/") + 2); blockCommentFinish(); } else { line = lhs; } } else if (!inBlockComment && line.contains("")) { return null; } blockCommentFinish(); line = line.substring(line.lastIndexOf("*/") + 2); } if (!inBlockComment && (line.trim().startsWith(" line = ""; } line = line.replace('\t', ' '); return line; }  String skipComments(String line);  }
@Test public void nullShouldThrowNullPointerException() { assertThatThrownBy(() -> this.commentSkipHelper.skipComments(null)) .isExactlyInstanceOf(NullPointerException.class); }
@Test public void emptyStringShouldReturnEmptyString() { assertThat(this.commentSkipHelper.skipComments("")).isEqualTo(""); }
@Test public void stringWithDoubleSlashCommentShouldReturnString() { String command = "start locator --name=loc1 assertThat(this.commentSkipHelper.skipComments(command)).isEqualTo(command); }
@Test public void stringWithSlashAsterCommentShouldRemoveComment() { String command = "start locator --name=loc1"; assertThat(this.commentSkipHelper.skipComments(command)) .isEqualTo("start locator --name=loc1"); }
@Test public void stringWithCommentWithoutSpacesShouldRemoveComment() { String command = "start locator--name=loc1"; assertThat(this.commentSkipHelper.skipComments(command)).isEqualTo("start locator--name=loc1"); }
@Test public void stringWithOpenCommentShouldReturnNull() { String command = "start locator /* --name=loc1"; assertThat(this.commentSkipHelper.skipComments(command)).isNull(); }
@Test public void stringWithCloseCommentShouldReturnString() { String command = "start locator */ --name=loc1"; assertThat(this.commentSkipHelper.skipComments(command)).isEqualTo(command); }
@Test public void stringWithMultiLineCommentShouldRemoveComment() { String command = "start locator --name=loc1"; assertThat(this.commentSkipHelper.skipComments(command)) .isEqualTo("start locator --name=loc1"); }
@Test public void stringWithCommentAtEndShouldRemoveComment() { String command = "start locator --name=loc1 "; assertThat(this.commentSkipHelper.skipComments(command)) .isEqualTo("start locator --name=loc1 "); }
@Test public void stringWithCommentAtBeginningShouldRemoveComment() { String command = " start locator --name=loc1"; assertThat(this.commentSkipHelper.skipComments(command)) .isEqualTo(" start locator --name=loc1"); }
@Test public void stringWithInsideOutCommentShouldMisbehave() { String command = "*/ this is a comment this is a comment this is a comment /* start locator --name=loc1"); }