123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
//// Source code recreated from a .class file by IntelliJ IDEA// (powered by Fernflower decompiler)//package org.junit;import org.hamcrest.Matcher;import org.hamcrest.MatcherAssert;import org.junit.internal.ArrayComparisonFailure;import org.junit.internal.ExactComparisonCriteria;import org.junit.internal.InexactComparisonCriteria;public class Assert { protected Assert() { } public static void assertTrue(String message, boolean condition) { if (!condition) { fail(message); } } public static void assertTrue(boolean condition) { assertTrue((String)null, condition); } public static void assertFalse(String message, boolean condition) { assertTrue(message, !condition); } public static void assertFalse(boolean condition) { assertFalse((String)null, condition); } public static void fail(String message) { if (message == null) { throw new AssertionError(); } else { throw new AssertionError(message); } } public static void fail() { fail((String)null); } public static void assertEquals(String message, Object expected, Object actual) { if (!equalsRegardingNull(expected, actual)) { if (expected instanceof String && actual instanceof String) { String cleanMessage = message == null ? "" : message; throw new ComparisonFailure(cleanMessage, (String)expected, (String)actual); } else { failNotEquals(message, expected, actual); } } } private static boolean equalsRegardingNull(Object expected, Object actual) { if (expected == null) { return actual == null; } else { return isEquals(expected, actual); } } private static boolean isEquals(Object expected, Object actual) { return expected.equals(actual); } public static void assertEquals(Object expected, Object actual) { assertEquals((String)null, (Object)expected, (Object)actual); } public static void assertNotEquals(String message, Object unexpected, Object actual) { if (equalsRegardingNull(unexpected, actual)) { failEquals(message, actual); } } public static void assertNotEquals(Object unexpected, Object actual) { assertNotEquals((String)null, unexpected, actual); } private static void failEquals(String message, Object actual) { String formatted = "Values should be different. "; if (message != null) { formatted = message + ". "; } formatted = formatted + "Actual: " + actual; fail(formatted); } public static void assertNotEquals(String message, long unexpected, long actual) { if (unexpected == actual) { failEquals(message, actual); } } public static void assertNotEquals(long unexpected, long actual) { assertNotEquals((String)null, unexpected, actual); } public static void assertNotEquals(String message, double unexpected, double actual, double delta) { if (!doubleIsDifferent(unexpected, actual, delta)) { failEquals(message, actual); } } public static void assertNotEquals(double unexpected, double actual, double delta) { assertNotEquals((String)null, unexpected, actual, delta); } public static void assertNotEquals(float unexpected, float actual, float delta) { assertNotEquals((String)null, unexpected, actual, delta); } public static void assertArrayEquals(String message, Object[] expecteds, Object[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); } public static void assertArrayEquals(Object[] expecteds, Object[] actuals) { assertArrayEquals((String)null, (Object[])expecteds, (Object[])actuals); } public static void assertArrayEquals(String message, boolean[] expecteds, boolean[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); } public static void assertArrayEquals(boolean[] expecteds, boolean[] actuals) { assertArrayEquals((String)null, (boolean[])expecteds, (boolean[])actuals); } public static void assertArrayEquals(String message, byte[] expecteds, byte[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); } public static void assertArrayEquals(byte[] expecteds, byte[] actuals) { assertArrayEquals((String)null, (byte[])expecteds, (byte[])actuals); } public static void assertArrayEquals(String message, char[] expecteds, char[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); } public static void assertArrayEquals(char[] expecteds, char[] actuals) { assertArrayEquals((String)null, (char[])expecteds, (char[])actuals); } public static void assertArrayEquals(String message, short[] expecteds, short[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); } public static void assertArrayEquals(short[] expecteds, short[] actuals) { assertArrayEquals((String)null, (short[])expecteds, (short[])actuals); } public static void assertArrayEquals(String message, int[] expecteds, int[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); } public static void assertArrayEquals(int[] expecteds, int[] actuals) { assertArrayEquals((String)null, (int[])expecteds, (int[])actuals); } public static void assertArrayEquals(String message, long[] expecteds, long[] actuals) throws ArrayComparisonFailure { internalArrayEquals(message, expecteds, actuals); } public static void assertArrayEquals(long[] expecteds, long[] actuals) { assertArrayEquals((String)null, (long[])expecteds, (long[])actuals); } public static void assertArrayEquals(String message, double[] expecteds, double[] actuals, double delta) throws ArrayComparisonFailure { (new InexactComparisonCriteria(delta)).arrayEquals(message, expecteds, actuals); } public static void assertArrayEquals(double[] expecteds, double[] actuals, double delta) { assertArrayEquals((String)null, expecteds, actuals, delta); } public static void assertArrayEquals(String message, float[] expecteds, float[] actuals, float delta) throws ArrayComparisonFailure { (new InexactComparisonCriteria(delta)).arrayEquals(message, expecteds, actuals); } public static void assertArrayEquals(float[] expecteds, float[] actuals, float delta) { assertArrayEquals((String)null, expecteds, actuals, delta); } private static void internalArrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure { (new ExactComparisonCriteria()).arrayEquals(message, expecteds, actuals); } public static void assertEquals(String message, double expected, double actual, double delta) { if (doubleIsDifferent(expected, actual, delta)) { failNotEquals(message, expected, actual); } } public static void assertEquals(String message, float expected, float actual, float delta) { if (floatIsDifferent(expected, actual, delta)) { failNotEquals(message, expected, actual); } } public static void assertNotEquals(String message, float unexpected, float actual, float delta) { if (!floatIsDifferent(unexpected, actual, delta)) { failEquals(message, actual); } } private static boolean doubleIsDifferent(double d1, double d2, double delta) { if (Double.compare(d1, d2) == 0) { return false; } else { return Math.abs(d1 - d2) > delta; } } private static boolean floatIsDifferent(float f1, float f2, float delta) { if (Float.compare(f1, f2) == 0) { return false; } else { return Math.abs(f1 - f2) > delta; } } public static void assertEquals(long expected, long actual) { assertEquals((String)null, expected, actual); } public static void assertEquals(String message, long expected, long actual) { if (expected != actual) { failNotEquals(message, expected, actual); } } /** @deprecated */ @Deprecated public static void assertEquals(double expected, double actual) { assertEquals((String)null, expected, actual); } /** @deprecated */ @Deprecated public static void assertEquals(String message, double expected, double actual) { fail("Use assertEquals(expected, actual, delta) to compare floating-point numbers"); } public static void assertEquals(double expected, double actual, double delta) { assertEquals((String)null, expected, actual, delta); } public static void assertEquals(float expected, float actual, float delta) { assertEquals((String)null, expected, actual, delta); } public static void assertNotNull(String message, Object object) { assertTrue(message, object != null); } public static void assertNotNull(Object object) { assertNotNull((String)null, object); } public static void assertNull(String message, Object object) { if (object != null) { failNotNull(message, object); } } public static void assertNull(Object object) { assertNull((String)null, object); } private static void failNotNull(String message, Object actual) { String formatted = ""; if (message != null) { formatted = message + " "; } fail(formatted + "expected null, but was:<" + actual + ">"); } public static void assertSame(String message, Object expected, Object actual) { if (expected != actual) { failNotSame(message, expected, actual); } } public static void assertSame(Object expected, Object actual) { assertSame((String)null, expected, actual); } public static void assertNotSame(String message, Object unexpected, Object actual) { if (unexpected == actual) { failSame(message); } } public static void assertNotSame(Object unexpected, Object actual) { assertNotSame((String)null, unexpected, actual); } private static void failSame(String message) { String formatted = ""; if (message != null) { formatted = message + " "; } fail(formatted + "expected not same"); } private static void failNotSame(String message, Object expected, Object actual) { String formatted = ""; if (message != null) { formatted = message + " "; } fail(formatted + "expected same:<" + expected + "> was not:<" + actual + ">"); } private static void failNotEquals(String message, Object expected, Object actual) { fail(format(message, expected, actual)); } static String format(String message, Object expected, Object actual) { String formatted = ""; if (message != null && !message.equals("")) { formatted = message + " "; } String expectedString = String.valueOf(expected); String actualString = String.valueOf(actual); return expectedString.equals(actualString) ? formatted + "expected: " + formatClassAndValue(expected, expectedString) + " but was: " + formatClassAndValue(actual, actualString) : formatted + "expected:<" + expectedString + "> but was:<" + actualString + ">"; } private static String formatClassAndValue(Object value, String valueString) { String className = value == null ? "null" : value.getClass().getName(); return className + "<" + valueString + ">"; } /** @deprecated */ @Deprecated public static void assertEquals(String message, Object[] expecteds, Object[] actuals) { assertArrayEquals(message, expecteds, actuals); } /** @deprecated */ @Deprecated public static void assertEquals(Object[] expecteds, Object[] actuals) { assertArrayEquals(expecteds, actuals); } public static <T> void assertThat(T actual, Matcher<? super T> matcher) { assertThat("", actual, matcher); } public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) { MatcherAssert.assertThat(reason, actual, matcher); }}