Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ecked warnings.

RELNOTES=n/a
PiperOrigin-RevId: 702798888
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Dec 4, 2024
1 parent 8a24204 commit 5d6e2bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@
@GwtCompatible(emulated = true)
@SuppressWarnings("deprecation") // tests of numerous deprecated methods
public class ThrowablesTest extends TestCase {
// We're testing that the method is in fact equivalent to throwing the exception directly.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testThrowIfUnchecked_unchecked() {
assertThrows(
SomeUncheckedException.class, () -> throwIfUnchecked(new SomeUncheckedException()));
}

// We're testing that the method is in fact equivalent to throwing the exception directly.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testThrowIfUnchecked_error() {
assertThrows(SomeError.class, () -> throwIfUnchecked(new SomeError()));
}
Expand All @@ -71,6 +75,8 @@ public void testThrowIfUnchecked_checked() {

@J2ktIncompatible
@GwtIncompatible // propagateIfPossible
// We're testing that the method is in fact equivalent to throwing the exception directly.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testPropagateIfPossible_noneDeclared_unchecked() {
assertThrows(
SomeUncheckedException.class, () -> propagateIfPossible(new SomeUncheckedException()));
Expand Down Expand Up @@ -151,12 +157,16 @@ public void testPropagateIfPossible_twoDeclared_neitherSame()
SomeOtherCheckedException.class);
}

// I guess it's technically a bug that ThrowIfUncheckedKnownUnchecked fires here.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testThrowIfUnchecked_null() {
assertThrows(NullPointerException.class, () -> throwIfUnchecked(null));
}

@J2ktIncompatible
@GwtIncompatible // propagateIfPossible
// I guess it's technically a bug that ThrowIfUncheckedKnownUnchecked fires here.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testPropageIfPossible_null() {
propagateIfPossible(null);
}
Expand Down
10 changes: 10 additions & 0 deletions guava-tests/test/com/google/common/base/ThrowablesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@
@GwtCompatible(emulated = true)
@SuppressWarnings("deprecation") // tests of numerous deprecated methods
public class ThrowablesTest extends TestCase {
// We're testing that the method is in fact equivalent to throwing the exception directly.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testThrowIfUnchecked_unchecked() {
assertThrows(
SomeUncheckedException.class, () -> throwIfUnchecked(new SomeUncheckedException()));
}

// We're testing that the method is in fact equivalent to throwing the exception directly.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testThrowIfUnchecked_error() {
assertThrows(SomeError.class, () -> throwIfUnchecked(new SomeError()));
}
Expand All @@ -71,6 +75,8 @@ public void testThrowIfUnchecked_checked() {

@J2ktIncompatible
@GwtIncompatible // propagateIfPossible
// We're testing that the method is in fact equivalent to throwing the exception directly.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testPropagateIfPossible_noneDeclared_unchecked() {
assertThrows(
SomeUncheckedException.class, () -> propagateIfPossible(new SomeUncheckedException()));
Expand Down Expand Up @@ -151,12 +157,16 @@ public void testPropagateIfPossible_twoDeclared_neitherSame()
SomeOtherCheckedException.class);
}

// I guess it's technically a bug that ThrowIfUncheckedKnownUnchecked fires here.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testThrowIfUnchecked_null() {
assertThrows(NullPointerException.class, () -> throwIfUnchecked(null));
}

@J2ktIncompatible
@GwtIncompatible // propagateIfPossible
// I guess it's technically a bug that ThrowIfUncheckedKnownUnchecked fires here.
@SuppressWarnings("ThrowIfUncheckedKnownUnchecked")
public void testPropageIfPossible_null() {
propagateIfPossible(null);
}
Expand Down

0 comments on commit 5d6e2bd

Please sign in to comment.