@@ -147,32 +147,32 @@ static public void assertEquals(Object expected, Object actual) {
147
147
/**
148
148
* Asserts that two objects are <b>not</b> equals. If they are, an
149
149
* {@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>,
151
151
* they are considered equal.
152
152
*
153
153
* @param message the identifying message for the {@link AssertionError} (<code>null</code>
154
154
* 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>
157
157
*/
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 );
162
162
}
163
163
}
164
164
165
165
/**
166
166
* Asserts that two objects are <b>not</b> equals. If they are, an
167
167
* {@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>,
169
169
* they are considered equal.
170
170
*
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>
173
173
*/
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 );
176
176
}
177
177
178
178
private static void failEquals (String message , Object actual ) {
@@ -191,60 +191,76 @@ private static void failEquals(String message, Object actual) {
191
191
*
192
192
* @param message the identifying message for the {@link AssertionError} (<code>null</code>
193
193
* 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>
196
196
*/
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 );
199
199
}
200
200
201
201
/**
202
202
* Asserts that two longs are <b>not</b> equals. If they are, an
203
203
* {@link AssertionError} without a message is thrown.
204
204
*
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>
207
207
*/
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 );
210
210
}
211
211
212
212
/**
213
- * Asserts that two doubles or floats are <b>not</b> equal to within a positive delta.
213
+ * Asserts that two doubles are <b>not</b> equal to within a positive delta.
214
214
* 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
216
216
* ignored. NaNs are considered equal:
217
217
* <code>assertNotEquals(Double.NaN, Double.NaN, *)</code> fails
218
218
*
219
219
* @param message the identifying message for the {@link AssertionError} (<code>null</code>
220
220
* okay)
221
- * @param first first value to check
222
- * @param second the value to check against <code>first </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
224
224
* <code>actual</code> for which both numbers are still
225
225
* considered equal.
226
226
*/
227
- static public void assertNotEquals (String message , double first ,
228
- double second , double delta ) {
229
- if (!doubleIsDifferent (first , second , delta )) {
230
- failEquals (message , new Double (first ));
227
+ static public void assertNotEquals (String message , double unexpected ,
228
+ double actual , double delta ) {
229
+ if (!doubleIsDifferent (unexpected , actual , delta )) {
230
+ failEquals (message , new Double (actual ));
231
231
}
232
232
}
233
233
234
234
/**
235
- * Asserts that two doubles or floats are <b>not</b> equal to within a positive delta.
236
- * If they are, an {@link AssertionError} is thrown. If the expected
235
+ * 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 unexpected
237
237
* value is infinity then the delta value is ignored.NaNs are considered
238
238
* equal: <code>assertNotEquals(Double.NaN, Double.NaN, *)</code> fails
239
239
*
240
- * @param first first value to check
241
- * @param second the value to check against <code>first</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
243
+ * <code>actual</code> for which both numbers are still
244
+ * considered equal.
245
+ */
246
+ static public void assertNotEquals (double unexpected , double actual , double delta ) {
247
+ assertNotEquals (null , unexpected , actual , delta );
248
+ }
249
+
250
+ /**
251
+ * 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 unexpected
253
+ * value is infinity then the delta value is ignored.NaNs are considered
254
+ * equal: <code>assertNotEquals(Float.NaN, Float.NaN, *)</code> fails
255
+ *
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
243
259
* <code>actual</code> for which both numbers are still
244
260
* considered equal.
245
261
*/
246
- static public void assertNotEquals (double first , double second , double delta ) {
247
- assertNotEquals (null , first , second , delta );
262
+ static public void assertNotEquals (float unexpected , float actual , float delta ) {
263
+ assertNotEquals (null , unexpected , actual , delta );
248
264
}
249
265
250
266
/**
@@ -512,14 +528,33 @@ static public void assertEquals(String message, double expected,
512
528
*/
513
529
static public void assertEquals (String message , float expected ,
514
530
float actual , float delta ) {
515
- if (Float .compare (expected , actual ) == 0 ) {
516
- return ;
517
- }
518
- if (!(Math .abs (expected - actual ) <= delta )) {
531
+ if (floatIsDifferent (expected , actual , delta )) {
519
532
failNotEquals (message , new Float (expected ), new Float (actual ));
520
533
}
521
534
}
522
535
536
+ /**
537
+ * Asserts that two floats are <b>not</b> equal to within a positive delta.
538
+ * If they are, an {@link AssertionError} is thrown with the given
539
+ * message. If the unexpected value is infinity then the delta value is
540
+ * ignored. NaNs are considered equal:
541
+ * <code>assertNotEquals(Float.NaN, Float.NaN, *)</code> fails
542
+ *
543
+ * @param message the identifying message for the {@link AssertionError} (<code>null</code>
544
+ * okay)
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
548
+ * <code>actual</code> for which both numbers are still
549
+ * considered equal.
550
+ */
551
+ static public void assertNotEquals (String message , float unexpected ,
552
+ float actual , float delta ) {
553
+ if (!floatIsDifferent (unexpected , actual , delta )) {
554
+ failEquals (message , new Float (actual ));
555
+ }
556
+ }
557
+
523
558
static private boolean doubleIsDifferent (double d1 , double d2 , double delta ) {
524
559
if (Double .compare (d1 , d2 ) == 0 ) {
525
560
return false ;
@@ -531,6 +566,17 @@ static private boolean doubleIsDifferent(double d1, double d2, double delta) {
531
566
return true ;
532
567
}
533
568
569
+ static private boolean floatIsDifferent (float f1 , float f2 , float delta ) {
570
+ if (Float .compare (f1 , f2 ) == 0 ) {
571
+ return false ;
572
+ }
573
+ if ((Math .abs (f1 - f2 ) <= delta )) {
574
+ return false ;
575
+ }
576
+
577
+ return true ;
578
+ }
579
+
534
580
/**
535
581
* Asserts that two longs are equal. If they are not, an
536
582
* {@link AssertionError} is thrown.
0 commit comments