From 6bf181df87c0d782e095ab6617cbc4240f0cf418 Mon Sep 17 00:00:00 2001 From: Tobias Thierer Date: Wed, 9 Sep 2020 15:56:56 +0100 Subject: [PATCH] HexDumpTest: Fix assertion. Commit e121ca0a629580422fb4ca6af998f19e5b22f033 added test coverage, including a helper function assertThrows(). The implementation of that method was buggy because it only failed the test if it was throwing the wrong kind of RuntimeException, instead of also when the code under test wasn't throwing an exception at all. This CL fixes the helper function. The test still passes (none of the code under test was relying on the incorrect assertion). Test: atest FrameworksCoreTests:com.android.internal.util.HexDumpTest Change-Id: I8fe3e70ada8b880a03e124cb48e204e7bb880e57 --- .../coretests/src/com/android/internal/util/HexDumpTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/tests/coretests/src/com/android/internal/util/HexDumpTest.java b/core/tests/coretests/src/com/android/internal/util/HexDumpTest.java index 4f0becc8ad5d8..f1cd89bf49f46 100644 --- a/core/tests/coretests/src/com/android/internal/util/HexDumpTest.java +++ b/core/tests/coretests/src/com/android/internal/util/HexDumpTest.java @@ -160,8 +160,9 @@ public final class HexDumpTest extends TestCase { private static void assertThrows(Class clazz, Runnable runnable) { try { runnable.run(); - } catch (RuntimeException exception) { - assertEquals(toStrackTrace(exception), clazz, exception.getClass()); + fail(); + } catch (RuntimeException expected) { + assertEquals(toStrackTrace(expected), clazz, expected.getClass()); } }