1b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpackage org.junit;
2b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
3b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.hamcrest.Description;
4b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.hamcrest.Matcher;
5b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.hamcrest.StringDescription;
6b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.junit.internal.ArrayComparisonFailure;
7b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.junit.internal.ExactComparisonCriteria;
8b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.junit.internal.InexactComparisonCriteria;
9b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
10b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot/**
11b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * A set of assertion methods useful for writing tests. Only failed assertions
12b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * are recorded. These methods can be used directly:
13b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <code>Assert.assertEquals(...)</code>, however, they read better if they
14b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * are referenced through static import:<br/>
15b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *
16b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <pre>
17b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * import static org.junit.Assert.*;
18b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *    ...
19b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *    assertEquals(...);
20b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * </pre>
21b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot *
22b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @see AssertionError
23b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */
24b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpublic class Assert {
25b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
26b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Protect constructor since it is a static only class
27b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
28b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	protected Assert() {
29b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
30b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
31b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
32b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that a condition is true. If it isn't it throws an
33b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} with the given message.
34b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
35b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
36b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
37b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
38b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param condition
39b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            condition to be checked
40b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
41b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertTrue(String message, boolean condition) {
42b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (!condition)
43b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			fail(message);
44b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
45b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
46b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
47b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that a condition is true. If it isn't it throws an
48b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} without a message.
49b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
50b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param condition
51b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            condition to be checked
52b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
53b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertTrue(boolean condition) {
54b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertTrue(null, condition);
55b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
56b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
57b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
58b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that a condition is false. If it isn't it throws an
59b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} with the given message.
60b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
61b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
62b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
63b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
64b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param condition
65b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            condition to be checked
66b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
67b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertFalse(String message, boolean condition) {
68b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertTrue(message, !condition);
69b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
70b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
71b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
72b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that a condition is false. If it isn't it throws an
73b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} without a message.
74b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
75b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param condition
76b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            condition to be checked
77b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
78b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertFalse(boolean condition) {
79b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertFalse(null, condition);
80b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
81b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
82b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
83b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Fails a test with the given message.
84b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
85b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
86b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
87b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
88b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @see AssertionError
89b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
90b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void fail(String message) {
91b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (message == null)
92b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			throw new AssertionError();
93b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		throw new AssertionError(message);
94b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
95b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
96b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
97b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Fails a test with no message.
98b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
99b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void fail() {
100b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		fail(null);
101b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
102b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
103b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
104b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two objects are equal. If they are not, an
105b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message. If
106b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>expected</code> and <code>actual</code> are <code>null</code>,
107b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * they are considered equal.
108b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
109b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
110b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
111b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
112b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expected
113b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected value
114b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
115b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            actual value
116b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
117b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertEquals(String message, Object expected,
118b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			Object actual) {
119b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (expected == null && actual == null)
120b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			return;
121b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (expected != null && isEquals(expected, actual))
122b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			return;
123b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		else if (expected instanceof String && actual instanceof String) {
124b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			String cleanMessage= message == null ? "" : message;
125b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			throw new ComparisonFailure(cleanMessage, (String) expected,
126b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot					(String) actual);
127b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		} else
128b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			failNotEquals(message, expected, actual);
129b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
130b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
131b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	private static boolean isEquals(Object expected, Object actual) {
132b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		return expected.equals(actual);
133b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
134b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
135b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
136b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two objects are equal. If they are not, an
137b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} without a message is thrown. If
138b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>expected</code> and <code>actual</code> are <code>null</code>,
139b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * they are considered equal.
140b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
141b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expected
142b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected value
143b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
144b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the value to check against <code>expected</code>
145b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
146b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertEquals(Object expected, Object actual) {
147b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertEquals(null, expected, actual);
148b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
149b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
150b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
151b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two object arrays are equal. If they are not, an
152b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message. If
153b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>expecteds</code> and <code>actuals</code> are <code>null</code>,
154b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * they are considered equal.
155b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
156b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
157b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
158b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
159b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
160b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
161b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected values.
162b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
163b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
164b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            actual values
165b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
166b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(String message, Object[] expecteds,
167b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			Object[] actuals) throws ArrayComparisonFailure {
168b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		internalArrayEquals(message, expecteds, actuals);
169b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
170b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
171b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
172b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two object arrays are equal. If they are not, an
173b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown. If <code>expected</code> and
174b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>actual</code> are <code>null</code>, they are considered
175b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * equal.
176b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
177b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
178b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
179b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected values
180b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
181b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
182b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            actual values
183b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
184b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(Object[] expecteds, Object[] actuals) {
185b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(null, expecteds, actuals);
186b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
187b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
188b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
189b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two byte arrays are equal. If they are not, an
190b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message.
191b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
192b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
193b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
194b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
195b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
196b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            byte array with expected values.
197b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
198b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            byte array with actual values
199b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
200b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(String message, byte[] expecteds,
201b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			byte[] actuals) throws ArrayComparisonFailure {
202b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		internalArrayEquals(message, expecteds, actuals);
203b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
204b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
205b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
206b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two byte arrays are equal. If they are not, an
207b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown.
208b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
209b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
210b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            byte array with expected values.
211b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
212b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            byte array with actual values
213b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
214b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(byte[] expecteds, byte[] actuals) {
215b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(null, expecteds, actuals);
216b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
217b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
218b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
219b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two char arrays are equal. If they are not, an
220b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message.
221b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
222b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
223b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
224b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
225b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
226b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            char array with expected values.
227b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
228b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            char array with actual values
229b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
230b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(String message, char[] expecteds,
231b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			char[] actuals) throws ArrayComparisonFailure {
232b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		internalArrayEquals(message, expecteds, actuals);
233b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
234b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
235b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
236b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two char arrays are equal. If they are not, an
237b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown.
238b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
239b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
240b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            char array with expected values.
241b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
242b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            char array with actual values
243b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
244b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(char[] expecteds, char[] actuals) {
245b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(null, expecteds, actuals);
246b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
247b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
248b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
249b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two short arrays are equal. If they are not, an
250b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message.
251b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
252b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
253b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
254b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
255b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
256b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            short array with expected values.
257b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
258b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            short array with actual values
259b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
260b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(String message, short[] expecteds,
261b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			short[] actuals) throws ArrayComparisonFailure {
262b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		internalArrayEquals(message, expecteds, actuals);
263b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
264b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
265b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
266b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two short arrays are equal. If they are not, an
267b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown.
268b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
269b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
270b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            short array with expected values.
271b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
272b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            short array with actual values
273b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
274b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(short[] expecteds, short[] actuals) {
275b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(null, expecteds, actuals);
276b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
277b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
278b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
279b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two int arrays are equal. If they are not, an
280b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message.
281b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
282b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
283b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
284b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
285b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
286b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            int array with expected values.
287b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
288b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            int array with actual values
289b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
290b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(String message, int[] expecteds,
291b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			int[] actuals) throws ArrayComparisonFailure {
292b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		internalArrayEquals(message, expecteds, actuals);
293b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
294b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
295b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
296b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two int arrays are equal. If they are not, an
297b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown.
298b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
299b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
300b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            int array with expected values.
301b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
302b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            int array with actual values
303b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
304b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(int[] expecteds, int[] actuals) {
305b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(null, expecteds, actuals);
306b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
307b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
308b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
309b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two long arrays are equal. If they are not, an
310b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message.
311b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
312b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
313b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
314b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
315b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
316b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            long array with expected values.
317b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
318b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            long array with actual values
319b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
320b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(String message, long[] expecteds,
321b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			long[] actuals) throws ArrayComparisonFailure {
322b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		internalArrayEquals(message, expecteds, actuals);
323b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
324b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
325b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
326b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two long arrays are equal. If they are not, an
327b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown.
328b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
329b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
330b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            long array with expected values.
331b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
332b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            long array with actual values
333b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
334b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(long[] expecteds, long[] actuals) {
335b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(null, expecteds, actuals);
336b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
337b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
338b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
339b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two double arrays are equal. If they are not, an
340b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message.
341b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
342b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
343b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
344b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
345b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
346b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            double array with expected values.
347b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
348b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            double array with actual values
349b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
350b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(String message, double[] expecteds,
351b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			double[] actuals, double delta) throws ArrayComparisonFailure {
352b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals);
353b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
354b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
355b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
356b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two double arrays are equal. If they are not, an
357b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown.
358b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
359b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
360b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            double array with expected values.
361b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
362b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            double array with actual values
363b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
364b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(double[] expecteds, double[] actuals, double delta) {
365b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(null, expecteds, actuals, delta);
366b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
367b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
368b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
369b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two float arrays are equal. If they are not, an
370b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message.
371b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
372b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
373b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
374b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
375b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
376b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            float array with expected values.
377b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
378b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            float array with actual values
379b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
380b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(String message, float[] expecteds,
381b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			float[] actuals, float delta) throws ArrayComparisonFailure {
382b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals);
383b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
384b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
385b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
386b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two float arrays are equal. If they are not, an
387b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown.
388b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
389b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
390b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            float array with expected values.
391b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
392b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            float array with actual values
393b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
394b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertArrayEquals(float[] expecteds, float[] actuals, float delta) {
395b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(null, expecteds, actuals, delta);
396b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
397b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
398b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
399b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two object arrays are equal. If they are not, an
400b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message. If
401b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>expecteds</code> and <code>actuals</code> are <code>null</code>,
402b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * they are considered equal.
403b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
404b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
405b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
406b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
407b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
408b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
409b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected values.
410b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
411b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
412b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            actual values
413b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
414b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	private static void internalArrayEquals(String message, Object expecteds,
415b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			Object actuals) throws ArrayComparisonFailure {
416b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		new ExactComparisonCriteria().arrayEquals(message, expecteds, actuals);
417b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
418b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
419b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
420b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two doubles or floats are equal to within a positive delta.
421b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * If they are not, an {@link AssertionError} is thrown with the given
422b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * message. If the expected value is infinity then the delta value is
423b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * ignored. NaNs are considered equal:
424b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>assertEquals(Double.NaN, Double.NaN, *)</code> passes
425b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
426b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
427b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
428b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
429b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expected
430b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected value
431b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
432b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the value to check against <code>expected</code>
433b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param delta
434b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the maximum delta between <code>expected</code> and
435b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            <code>actual</code> for which both numbers are still
436b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            considered equal.
437b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
438b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertEquals(String message, double expected,
439b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			double actual, double delta) {
440b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (Double.compare(expected, actual) == 0)
441b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			return;
442b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (!(Math.abs(expected - actual) <= delta))
443b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			failNotEquals(message, new Double(expected), new Double(actual));
444b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
445b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
446b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
447b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two longs are equal. If they are not, an
448b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown.
449b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
450b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expected
451b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected long value.
452b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
453b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            actual long value
454b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
455b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertEquals(long expected, long actual) {
456b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertEquals(null, expected, actual);
457b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
458b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
459b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
460b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two longs are equal. If they are not, an
461b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message.
462b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
463b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
464b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
465b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
466b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expected
467b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            long expected value.
468b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
469b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            long actual value
470b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
471b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertEquals(String message, long expected, long actual) {
472b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertEquals(message, (Long) expected, (Long) actual);
473b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
474b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
475b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
476b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @deprecated Use
477b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *             <code>assertEquals(double expected, double actual, double delta)</code>
478b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *             instead
479b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
480b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	@Deprecated
481b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertEquals(double expected, double actual) {
482b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertEquals(null, expected, actual);
483b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
484b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
485b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
486b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @deprecated Use
487b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *             <code>assertEquals(String message, double expected, double actual, double delta)</code>
488b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *             instead
489b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
490b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	@Deprecated
491b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertEquals(String message, double expected,
492b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			double actual) {
493b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		fail("Use assertEquals(expected, actual, delta) to compare floating-point numbers");
494b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
495b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
496b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
497b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two doubles or floats are equal to within a positive delta.
498b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * If they are not, an {@link AssertionError} is thrown. If the expected
499b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * value is infinity then the delta value is ignored.NaNs are considered
500b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * equal: <code>assertEquals(Double.NaN, Double.NaN, *)</code> passes
501b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
502b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expected
503b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected value
504b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
505b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the value to check against <code>expected</code>
506b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param delta
507b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the maximum delta between <code>expected</code> and
508b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            <code>actual</code> for which both numbers are still
509b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            considered equal.
510b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
511b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertEquals(double expected, double actual, double delta) {
512b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertEquals(null, expected, actual, delta);
513b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
514b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
515b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
516b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that an object isn't null. If it is an {@link AssertionError} is
517b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * thrown with the given message.
518b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
519b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
520b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
521b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
522b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param object
523b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object to check or <code>null</code>
524b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
525b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertNotNull(String message, Object object) {
526b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertTrue(message, object != null);
527b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
528b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
529b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
530b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that an object isn't null. If it is an {@link AssertionError} is
531b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * thrown.
532b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
533b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param object
534b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object to check or <code>null</code>
535b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
536b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertNotNull(Object object) {
537b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertNotNull(null, object);
538b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
539b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
540b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
541b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that an object is null. If it is not, an {@link AssertionError}
542b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * is thrown with the given message.
543b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
544b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
545b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
546b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
547b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param object
548b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object to check or <code>null</code>
549b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
550b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertNull(String message, Object object) {
551b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertTrue(message, object == null);
552b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
553b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
554b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
555b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that an object is null. If it isn't an {@link AssertionError} is
556b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * thrown.
557b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
558b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param object
559b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object to check or <code>null</code>
560b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
561b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertNull(Object object) {
562b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertNull(null, object);
563b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
564b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
565b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
566b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two objects refer to the same object. If they are not, an
567b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message.
568b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
569b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
570b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
571b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
572b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expected
573b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the expected object
574b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
575b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the object to compare to <code>expected</code>
576b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
577b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertSame(String message, Object expected, Object actual) {
578b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (expected == actual)
579b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			return;
580b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		failNotSame(message, expected, actual);
581b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
582b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
583b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
584b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two objects refer to the same object. If they are not the
585b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * same, an {@link AssertionError} without a message is thrown.
586b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
587b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expected
588b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the expected object
589b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
590b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the object to compare to <code>expected</code>
591b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
592b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertSame(Object expected, Object actual) {
593b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertSame(null, expected, actual);
594b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
595b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
596b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
597b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two objects do not refer to the same object. If they do
598b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * refer to the same object, an {@link AssertionError} is thrown with the
599b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * given message.
600b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
601b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
602b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
603b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
604b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param unexpected
605b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the object you don't expect
606b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
607b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the object to compare to <code>unexpected</code>
608b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
609b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertNotSame(String message, Object unexpected,
610b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			Object actual) {
611b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (unexpected == actual)
612b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			failSame(message);
613b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
614b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
615b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
616b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two objects do not refer to the same object. If they do
617b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * refer to the same object, an {@link AssertionError} without a message is
618b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * thrown.
619b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
620b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param unexpected
621b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the object you don't expect
622b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
623b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the object to compare to <code>unexpected</code>
624b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
625b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static public void assertNotSame(Object unexpected, Object actual) {
626b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertNotSame(null, unexpected, actual);
627b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
628b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
629b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static private void failSame(String message) {
630b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		String formatted= "";
631b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (message != null)
632b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			formatted= message + " ";
633b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		fail(formatted + "expected not same");
634b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
635b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
636b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static private void failNotSame(String message, Object expected,
637b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			Object actual) {
638b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		String formatted= "";
639b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (message != null)
640b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			formatted= message + " ";
641b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		fail(formatted + "expected same:<" + expected + "> was not:<" + actual
642b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot				+ ">");
643b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
644b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
645b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static private void failNotEquals(String message, Object expected,
646b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			Object actual) {
647b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		fail(format(message, expected, actual));
648b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
649b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
650b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	static String format(String message, Object expected, Object actual) {
651b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		String formatted= "";
652b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (message != null && !message.equals(""))
653b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			formatted= message + " ";
654b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		String expectedString= String.valueOf(expected);
655b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		String actualString= String.valueOf(actual);
656b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (expectedString.equals(actualString))
657b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			return formatted + "expected: "
658b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot					+ formatClassAndValue(expected, expectedString)
659b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot					+ " but was: " + formatClassAndValue(actual, actualString);
660b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		else
661b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			return formatted + "expected:<" + expectedString + "> but was:<"
662b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot					+ actualString + ">";
663b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
664b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
665b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	private static String formatClassAndValue(Object value, String valueString) {
666b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		String className= value == null ? "null" : value.getClass().getName();
667b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		return className + "<" + valueString + ">";
668b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
669b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
670b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
671b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two object arrays are equal. If they are not, an
672b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown with the given message. If
673b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>expecteds</code> and <code>actuals</code> are <code>null</code>,
674b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * they are considered equal.
675b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
676b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param message
677b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the identifying message for the {@link AssertionError} (<code>null</code>
678b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            okay)
679b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
680b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
681b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected values.
682b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
683b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
684b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            actual values
685b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @deprecated use assertArrayEquals
686b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
687b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	@Deprecated
688b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertEquals(String message, Object[] expecteds,
689b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			Object[] actuals) {
690b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(message, expecteds, actuals);
691b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
692b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
693b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
694b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that two object arrays are equal. If they are not, an
695b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * {@link AssertionError} is thrown. If <code>expected</code> and
696b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>actual</code> are <code>null</code>, they are considered
697b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * equal.
698b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
699b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param expecteds
700b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
701b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            expected values
702b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actuals
703b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            Object array or array of arrays (multi-dimensional array) with
704b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            actual values
705b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @deprecated use assertArrayEquals
706b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
707b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	@Deprecated
708b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static void assertEquals(Object[] expecteds, Object[] actuals) {
709b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertArrayEquals(expecteds, actuals);
710b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
711b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
712b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
713b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that <code>actual</code> satisfies the condition specified by
714b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>matcher</code>. If not, an {@link AssertionError} is thrown with
715b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * information about the matcher and failing value. Example:
716b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
717b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <pre>
718b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *   assertThat(0, is(1)); // fails:
719b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *     // failure message:
720b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *     // expected: is &lt;1&gt;
721b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *     // got value: &lt;0&gt;
722b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *   assertThat(0, is(not(1))) // passes
723b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * </pre>
724b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
725b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param <T>
726b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the static type accepted by the matcher (this can flag obvious
727b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            compile-time problems such as {@code assertThat(1, is("a"))}
728b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
729b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the computed value being compared
730b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param matcher
731b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            an expression, built of {@link Matcher}s, specifying allowed
732b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            values
733b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
734b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @see org.hamcrest.CoreMatchers
735b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @see org.junit.matchers.JUnitMatchers
736b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
737b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static <T> void assertThat(T actual, Matcher<T> matcher) {
738b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		assertThat("", actual, matcher);
739b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
740b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot
741b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	/**
742b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * Asserts that <code>actual</code> satisfies the condition specified by
743b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <code>matcher</code>. If not, an {@link AssertionError} is thrown with
744b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * the reason and information about the matcher and failing value. Example:
745b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
746b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * <pre>
747b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * :
748b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *   assertThat(&quot;Help! Integers don't work&quot;, 0, is(1)); // fails:
749b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *     // failure message:
750b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *     // Help! Integers don't work
751b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *     // expected: is &lt;1&gt;
752b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *     // got value: &lt;0&gt;
753b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *   assertThat(&quot;Zero is one&quot;, 0, is(not(1))) // passes
754b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * </pre>
755b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
756b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param reason
757b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            additional information about the error
758b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param <T>
759b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the static type accepted by the matcher (this can flag obvious
760b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            compile-time problems such as {@code assertThat(1, is("a"))}
761b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param actual
762b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            the computed value being compared
763b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @param matcher
764b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            an expression, built of {@link Matcher}s, specifying allowed
765b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *            values
766b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 *
767b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @see org.hamcrest.CoreMatchers
768b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 * @see org.junit.matchers.JUnitMatchers
769b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	 */
770b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	public static <T> void assertThat(String reason, T actual,
771b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			Matcher<T> matcher) {
772b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		if (!matcher.matches(actual)) {
773b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			Description description= new StringDescription();
774b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			description.appendText(reason);
775b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			description.appendText("\nExpected: ");
776b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			description.appendDescriptionOf(matcher);
777b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			description.appendText("\n     got: ");
778b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			description.appendValue(actual);
779b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			description.appendText("\n");
780b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot			throw new java.lang.AssertionError(description.toString());
781b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot		}
782b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot	}
783b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot}
784