Skip to content

Commit 7027d9f

Browse files
graememorganError Prone Team
authored andcommitted
Add negative test cases for AlwaysThrows with non-literal arguments.
PiperOrigin-RevId: 837246366
1 parent 8669adb commit 7027d9f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

core/src/test/java/com/google/errorprone/bugpatterns/AlwaysThrowsTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ void f() {
4545
.doTest();
4646
}
4747

48+
@Test
49+
public void negative_nonLiteral() {
50+
testHelper
51+
.addSourceLines(
52+
"Test.java",
53+
"""
54+
import java.time.Instant;
55+
56+
class T {
57+
void f() {
58+
Instant.parse(toString() + "foo");
59+
}
60+
}
61+
""")
62+
.doTest();
63+
}
64+
4865
@Test
4966
public void immutableMapThrows() {
5067
testHelper
@@ -218,4 +235,19 @@ class Test {
218235
""")
219236
.doTest();
220237
}
238+
239+
@Test
240+
public void uuidFromString_withNonLiteral() {
241+
testHelper
242+
.addSourceLines(
243+
"Test.java",
244+
"""
245+
import java.util.UUID;
246+
247+
class Test {
248+
private final UUID uuid = UUID.fromString(toString());
249+
}
250+
""")
251+
.doTest();
252+
}
221253
}

0 commit comments

Comments
 (0)