junit expected exceptions

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1147531 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2011-07-17 05:33:33 +00:00
parent 2b0b97178b
commit fe235bbb83
1 changed files with 120 additions and 121 deletions

View File

@ -348,19 +348,18 @@ protected void testCreateBigDecimalFailure(String str) {
// min/max tests // min/max tests
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@Test(expected = IllegalArgumentException.class)
public void testMinLong_nullArray() {
NumberUtils.min((long[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMinLong_emptyArray() {
NumberUtils.min(new long[0]);
}
@Test @Test
public void testMinLong() { public void testMinLong() {
final long[] l = null;
try {
NumberUtils.min(l);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.min(new long[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"min(long[]) failed for array length 1", "min(long[]) failed for array length 1",
5, 5,
@ -375,19 +374,18 @@ public void testMinLong() {
assertEquals(-10, NumberUtils.min(new long[] { -5, 0, -10, 5, 10 })); assertEquals(-10, NumberUtils.min(new long[] { -5, 0, -10, 5, 10 }));
} }
@Test(expected = IllegalArgumentException.class)
public void testMinInt_nullArray() {
NumberUtils.min((int[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMinInt_emptyArray() {
NumberUtils.min(new int[0]);
}
@Test @Test
public void testMinInt() { public void testMinInt() {
final int[] i = null;
try {
NumberUtils.min(i);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.min(new int[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"min(int[]) failed for array length 1", "min(int[]) failed for array length 1",
5, 5,
@ -402,19 +400,18 @@ public void testMinInt() {
assertEquals(-10, NumberUtils.min(new int[] { -5, 0, -10, 5, 10 })); assertEquals(-10, NumberUtils.min(new int[] { -5, 0, -10, 5, 10 }));
} }
@Test(expected = IllegalArgumentException.class)
public void testMinShort_nullArray() {
NumberUtils.min((short[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMinShort_emptyArray() {
NumberUtils.min(new short[0]);
}
@Test @Test
public void testMinShort() { public void testMinShort() {
final short[] s = null;
try {
NumberUtils.min(s);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.min(new short[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"min(short[]) failed for array length 1", "min(short[]) failed for array length 1",
5, 5,
@ -429,19 +426,18 @@ public void testMinShort() {
assertEquals(-10, NumberUtils.min(new short[] { -5, 0, -10, 5, 10 })); assertEquals(-10, NumberUtils.min(new short[] { -5, 0, -10, 5, 10 }));
} }
@Test(expected = IllegalArgumentException.class)
public void testMinByte_nullArray() {
NumberUtils.min((byte[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMinByte_emptyArray() {
NumberUtils.min(new byte[0]);
}
@Test @Test
public void testMinByte() { public void testMinByte() {
final byte[] b = null;
try {
NumberUtils.min(b);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.min(new byte[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"min(byte[]) failed for array length 1", "min(byte[]) failed for array length 1",
5, 5,
@ -456,19 +452,18 @@ public void testMinByte() {
assertEquals(-10, NumberUtils.min(new byte[] { -5, 0, -10, 5, 10 })); assertEquals(-10, NumberUtils.min(new byte[] { -5, 0, -10, 5, 10 }));
} }
@Test(expected = IllegalArgumentException.class)
public void testMinDouble_nullArray() {
NumberUtils.min((double[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMinDouble_emptyArray() {
NumberUtils.min(new double[0]);
}
@Test @Test
public void testMinDouble() { public void testMinDouble() {
final double[] d = null;
try {
NumberUtils.min(d);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.min(new double[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"min(double[]) failed for array length 1", "min(double[]) failed for array length 1",
5.12, 5.12,
@ -490,19 +485,18 @@ public void testMinDouble() {
assertEquals(-10, NumberUtils.min(new double[] { -5, 0, -10, 5, 10 }), 0.0001); assertEquals(-10, NumberUtils.min(new double[] { -5, 0, -10, 5, 10 }), 0.0001);
} }
@Test(expected = IllegalArgumentException.class)
public void testMinFloat_nullArray() {
NumberUtils.min((float[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMinFloat_emptyArray() {
NumberUtils.min(new float[0]);
}
@Test @Test
public void testMinFloat() { public void testMinFloat() {
final float[] f = null;
try {
NumberUtils.min(f);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.min(new float[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"min(float[]) failed for array length 1", "min(float[]) failed for array length 1",
5.9f, 5.9f,
@ -524,19 +518,18 @@ public void testMinFloat() {
assertEquals(-10, NumberUtils.min(new float[] { -5, 0, -10, 5, 10 }), 0.0001f); assertEquals(-10, NumberUtils.min(new float[] { -5, 0, -10, 5, 10 }), 0.0001f);
} }
@Test(expected = IllegalArgumentException.class)
public void testMaxLong_nullArray() {
NumberUtils.max((long[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMaxLong_emptyArray() {
NumberUtils.max(new long[0]);
}
@Test @Test
public void testMaxLong() { public void testMaxLong() {
final long[] l = null;
try {
NumberUtils.max(l);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.max(new long[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"max(long[]) failed for array length 1", "max(long[]) failed for array length 1",
5, 5,
@ -555,19 +548,18 @@ public void testMaxLong() {
assertEquals(10, NumberUtils.max(new long[] { -5, 0, 10, 5, -10 })); assertEquals(10, NumberUtils.max(new long[] { -5, 0, 10, 5, -10 }));
} }
@Test(expected = IllegalArgumentException.class)
public void testMaxInt_nullArray() {
NumberUtils.max((int[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMaxInt_emptyArray() {
NumberUtils.max(new int[0]);
}
@Test @Test
public void testMaxInt() { public void testMaxInt() {
final int[] i = null;
try {
NumberUtils.max(i);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.max(new int[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"max(int[]) failed for array length 1", "max(int[]) failed for array length 1",
5, 5,
@ -586,19 +578,18 @@ public void testMaxInt() {
assertEquals(10, NumberUtils.max(new int[] { -5, 0, 10, 5, -10 })); assertEquals(10, NumberUtils.max(new int[] { -5, 0, 10, 5, -10 }));
} }
@Test(expected = IllegalArgumentException.class)
public void testMaxShort_nullArray() {
NumberUtils.max((short[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMaxShort_emptyArray() {
NumberUtils.max(new short[0]);
}
@Test @Test
public void testMaxShort() { public void testMaxShort() {
final short[] s = null;
try {
NumberUtils.max(s);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.max(new short[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"max(short[]) failed for array length 1", "max(short[]) failed for array length 1",
5, 5,
@ -617,19 +608,18 @@ public void testMaxShort() {
assertEquals(10, NumberUtils.max(new short[] { -5, 0, 10, 5, -10 })); assertEquals(10, NumberUtils.max(new short[] { -5, 0, 10, 5, -10 }));
} }
@Test(expected = IllegalArgumentException.class)
public void testMaxByte_nullArray() {
NumberUtils.max((byte[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMaxByte_emptyArray() {
NumberUtils.max(new byte[0]);
}
@Test @Test
public void testMaxByte() { public void testMaxByte() {
final byte[] b = null;
try {
NumberUtils.max(b);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.max(new byte[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"max(byte[]) failed for array length 1", "max(byte[]) failed for array length 1",
5, 5,
@ -648,6 +638,16 @@ public void testMaxByte() {
assertEquals(10, NumberUtils.max(new byte[] { -5, 0, 10, 5, -10 })); assertEquals(10, NumberUtils.max(new byte[] { -5, 0, 10, 5, -10 }));
} }
@Test(expected = IllegalArgumentException.class)
public void testMaxDouble_nullArray() {
NumberUtils.max((double[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMaxDouble_emptyArray() {
NumberUtils.max(new double[0]);
}
@Test @Test
public void testMaxDouble() { public void testMaxDouble() {
final double[] d = null; final double[] d = null;
@ -682,19 +682,18 @@ public void testMaxDouble() {
assertEquals(10, NumberUtils.max(new double[] { -5, 0, 10, 5, -10 }), 0.0001); assertEquals(10, NumberUtils.max(new double[] { -5, 0, 10, 5, -10 }), 0.0001);
} }
@Test(expected = IllegalArgumentException.class)
public void testMaxFloat_nullArray() {
NumberUtils.max((float[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void testMaxFloat_emptyArray() {
NumberUtils.max(new float[0]);
}
@Test @Test
public void testMaxFloat() { public void testMaxFloat() {
final float[] f = null;
try {
NumberUtils.max(f);
fail("No exception was thrown for null input.");
} catch (IllegalArgumentException ex) {}
try {
NumberUtils.max(new float[0]);
fail("No exception was thrown for empty input.");
} catch (IllegalArgumentException ex) {}
assertEquals( assertEquals(
"max(float[]) failed for array length 1", "max(float[]) failed for array length 1",
5.1f, 5.1f,