Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Aug 25, 2023
1 parent b8cd9ac commit 74228e6
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -292,19 +292,26 @@ public void suggestSuppressionOnMethodRef() throws IOException {
}

@Test
public void suggestCastToNonNullMultiLine() throws IOException {
public void suggestCastToNonNullPreserveComments() throws IOException {
makeTestHelper()
.addInputLines(
"Test.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"class Test {",
" Object x = new Object();",
" static class Foo { @Nullable Object getObj() { return null; } }",
" Object test1(Foo f) {",
" return f",
" // comment that should not be deleted",
" .getObj();",
" }",
" void test2(Foo f) {",
" x = f.getObj(); // comment that should not be deleted",
" }",
" Object test3(Foo f) {",
" return f./* keep this comment */getObj();",
" }",
"}")
.addOutputLines(
"out/Test.java",
Expand All @@ -313,12 +320,19 @@ public void suggestCastToNonNullMultiLine() throws IOException {
"",
"import javax.annotation.Nullable;",
"class Test {",
" Object x = new Object();",
" static class Foo { @Nullable Object getObj() { return null; } }",
" Object test1(Foo f) {",
" return castToNonNull(f",
" // comment that should not be deleted",
" .getObj());",
" }",
" void test2(Foo f) {",
" x = castToNonNull(f.getObj()); // comment that should not be deleted",
" }",
" Object test3(Foo f) {",
" return castToNonNull(f./* keep this comment */getObj());",
" }",
"}")
.doTest(TEXT_MATCH);
}
Expand Down

0 comments on commit 74228e6

Please sign in to comment.