Skip to content

Commit f5c7fe4

Browse files
committed
Change failure message in assertNotEquals() to show actual instead of
unexpected, to be consistent with assertNotSame(). Change the parameter names from first and second to unexpected and actual.
1 parent 78b4a89 commit f5c7fe4

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

src/main/java/org/junit/Assert.java

+46-46
Original file line numberDiff line numberDiff line change
@@ -147,32 +147,32 @@ static public void assertEquals(Object expected, Object actual) {
147147
/**
148148
* Asserts that two objects are <b>not</b> equals. If they are, an
149149
* {@link AssertionError} is thrown with the given message. If
150-
* <code>first</code> and <code>second</code> are <code>null</code>,
150+
* <code>unexpected</code> and <code>actual</code> are <code>null</code>,
151151
* they are considered equal.
152152
*
153153
* @param message the identifying message for the {@link AssertionError} (<code>null</code>
154154
* okay)
155-
* @param first first value to check
156-
* @param second the value to check against <code>first</code>
155+
* @param unexpected unexpected value to check
156+
* @param actual the value to check against <code>unexpected</code>
157157
*/
158-
static public void assertNotEquals(String message, Object first,
159-
Object second) {
160-
if (equalsRegardingNull(first, second)) {
161-
failEquals(message, first);
158+
static public void assertNotEquals(String message, Object unexpected,
159+
Object actual) {
160+
if (equalsRegardingNull(unexpected, actual)) {
161+
failEquals(message, actual);
162162
}
163163
}
164164

165165
/**
166166
* Asserts that two objects are <b>not</b> equals. If they are, an
167167
* {@link AssertionError} without a message is thrown. If
168-
* <code>first</code> and <code>second</code> are <code>null</code>,
168+
* <code>unexpected</code> and <code>actual</code> are <code>null</code>,
169169
* they are considered equal.
170170
*
171-
* @param first first value to check
172-
* @param second the value to check against <code>first</code>
171+
* @param unexpected unexpected value to check
172+
* @param actual the value to check against <code>unexpected</code>
173173
*/
174-
static public void assertNotEquals(Object first, Object second) {
175-
assertNotEquals(null, first, second);
174+
static public void assertNotEquals(Object unexpected, Object actual) {
175+
assertNotEquals(null, unexpected, actual);
176176
}
177177

178178
private static void failEquals(String message, Object actual) {
@@ -191,76 +191,76 @@ private static void failEquals(String message, Object actual) {
191191
*
192192
* @param message the identifying message for the {@link AssertionError} (<code>null</code>
193193
* okay)
194-
* @param first first value to check
195-
* @param second the value to check against <code>first</code>
194+
* @param unexpected unexpected value to check
195+
* @param actual the value to check against <code>unexpected</code>
196196
*/
197-
static public void assertNotEquals(String message, long first, long second) {
198-
assertNotEquals(message, (Long) first, (Long) second);
197+
static public void assertNotEquals(String message, long unexpected, long actual) {
198+
assertNotEquals(message, (Long) unexpected, (Long) actual);
199199
}
200200

201201
/**
202202
* Asserts that two longs are <b>not</b> equals. If they are, an
203203
* {@link AssertionError} without a message is thrown.
204204
*
205-
* @param first first value to check
206-
* @param second the value to check against <code>first</code>
205+
* @param unexpected unexpected value to check
206+
* @param actual the value to check against <code>unexpected</code>
207207
*/
208-
static public void assertNotEquals(long first, long second) {
209-
assertNotEquals(null, first, second);
208+
static public void assertNotEquals(long unexpected, long actual) {
209+
assertNotEquals(null, unexpected, actual);
210210
}
211211

212212
/**
213213
* Asserts that two doubles are <b>not</b> equal to within a positive delta.
214214
* If they are, an {@link AssertionError} is thrown with the given
215-
* message. If the expected value is infinity then the delta value is
215+
* message. If the unexpected value is infinity then the delta value is
216216
* ignored. NaNs are considered equal:
217217
* <code>assertNotEquals(Double.NaN, Double.NaN, *)</code> fails
218218
*
219219
* @param message the identifying message for the {@link AssertionError} (<code>null</code>
220220
* okay)
221-
* @param expected expected value
222-
* @param actual the value to check against <code>expected</code>
223-
* @param delta the maximum delta between <code>expected</code> and
221+
* @param unexpected unexpected value
222+
* @param actual the value to check against <code>unexpected</code>
223+
* @param delta the maximum delta between <code>unexpected</code> and
224224
* <code>actual</code> for which both numbers are still
225225
* considered equal.
226226
*/
227-
static public void assertNotEquals(String message, double expected,
227+
static public void assertNotEquals(String message, double unexpected,
228228
double actual, double delta) {
229-
if (!doubleIsDifferent(expected, actual, delta)) {
230-
failEquals(message, new Double(expected));
229+
if (!doubleIsDifferent(unexpected, actual, delta)) {
230+
failEquals(message, new Double(actual));
231231
}
232232
}
233233

234234
/**
235235
* Asserts that two doubles are <b>not</b> equal to within a positive delta.
236-
* If they are, an {@link AssertionError} is thrown. If the expected
236+
* If they are, an {@link AssertionError} is thrown. If the unexpected
237237
* value is infinity then the delta value is ignored.NaNs are considered
238238
* equal: <code>assertNotEquals(Double.NaN, Double.NaN, *)</code> fails
239239
*
240-
* @param expected expected value
241-
* @param actual the value to check against <code>expected</code>
242-
* @param delta the maximum delta between <code>expected</code> and
240+
* @param unexpected unexpected value
241+
* @param actual the value to check against <code>unexpected</code>
242+
* @param delta the maximum delta between <code>unexpected</code> and
243243
* <code>actual</code> for which both numbers are still
244244
* considered equal.
245245
*/
246-
static public void assertNotEquals(double expected, double actual, double delta) {
247-
assertNotEquals(null, expected, actual, delta);
246+
static public void assertNotEquals(double unexpected, double actual, double delta) {
247+
assertNotEquals(null, unexpected, actual, delta);
248248
}
249249

250250
/**
251251
* Asserts that two floats are <b>not</b> equal to within a positive delta.
252-
* If they are, an {@link AssertionError} is thrown. If the expected
252+
* If they are, an {@link AssertionError} is thrown. If the unexpected
253253
* value is infinity then the delta value is ignored.NaNs are considered
254254
* equal: <code>assertNotEquals(Float.NaN, Float.NaN, *)</code> fails
255255
*
256-
* @param expected expected value
257-
* @param actual the value to check against <code>expected</code>
258-
* @param delta the maximum delta between <code>expected</code> and
256+
* @param unexpected unexpected value
257+
* @param actual the value to check against <code>unexpected</code>
258+
* @param delta the maximum delta between <code>unexpected</code> and
259259
* <code>actual</code> for which both numbers are still
260260
* considered equal.
261261
*/
262-
static public void assertNotEquals(float expected, float actual, float delta) {
263-
assertNotEquals(null, expected, actual, delta);
262+
static public void assertNotEquals(float unexpected, float actual, float delta) {
263+
assertNotEquals(null, unexpected, actual, delta);
264264
}
265265

266266
/**
@@ -536,22 +536,22 @@ static public void assertEquals(String message, float expected,
536536
/**
537537
* Asserts that two floats are <b>not</b> equal to within a positive delta.
538538
* If they are, an {@link AssertionError} is thrown with the given
539-
* message. If the expected value is infinity then the delta value is
539+
* message. If the unexpected value is infinity then the delta value is
540540
* ignored. NaNs are considered equal:
541541
* <code>assertNotEquals(Float.NaN, Float.NaN, *)</code> fails
542542
*
543543
* @param message the identifying message for the {@link AssertionError} (<code>null</code>
544544
* okay)
545-
* @param expected expected value
546-
* @param actual the value to check against <code>expected</code>
547-
* @param delta the maximum delta between <code>expected</code> and
545+
* @param unexpected unexpected value
546+
* @param actual the value to check against <code>unexpected</code>
547+
* @param delta the maximum delta between <code>unexpected</code> and
548548
* <code>actual</code> for which both numbers are still
549549
* considered equal.
550550
*/
551-
static public void assertNotEquals(String message, float expected,
551+
static public void assertNotEquals(String message, float unexpected,
552552
float actual, float delta) {
553-
if (!floatIsDifferent(expected, actual, delta)) {
554-
failEquals(message, new Float(expected));
553+
if (!floatIsDifferent(unexpected, actual, delta)) {
554+
failEquals(message, new Float(actual));
555555
}
556556
}
557557

0 commit comments

Comments
 (0)