*/
public class TestJPEGQTable implements Testlet
{
public void test(TestHarness h)
{
JPEGQTable t;
boolean constructionFailed;
int[] table;
int[] K1LuminanceValues =
{
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68, 109, 103, 77,
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
};
int[] K1Div2LuminanceValues =
{
8, 6, 5, 8, 12, 20, 26, 31,
6, 6, 7, 10, 13, 29, 30, 28,
7, 7, 8, 12, 20, 29, 35, 28,
7, 9, 11, 15, 26, 44, 40, 31,
9, 11, 19, 28, 34, 55, 52, 39,
12, 18, 28, 32, 41, 52, 57, 46,
25, 32, 39, 44, 52, 61, 60, 51,
36, 46, 48, 49, 56, 50, 52, 50
};
int[] K2ChrominanceValues =
{
17, 18, 24, 47, 99, 99, 99, 99,
18, 21, 26, 66, 99, 99, 99, 99,
24, 26, 56, 99, 99, 99, 99, 99,
47, 66, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
int[] K2Div2ChrominanceValues =
{
9, 9, 12, 24, 50, 50, 50, 50,
9, 11, 13, 33, 50, 50, 50, 50,
12, 13, 28, 50, 50, 50, 50, 50,
24, 33, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50
};
// Test that it is impossible to construct an invalid quantization
// table.
// table argument is null
constructionFailed = false;
try
{
t = new JPEGQTable(null);
}
catch (IllegalArgumentException e)
{
constructionFailed = true;
}
h.check(constructionFailed);
// table has length less than 64
constructionFailed = false;
int[] smallTable = new int[K1LuminanceValues.length - 20];
System.arraycopy(K1LuminanceValues, 0, smallTable, 0, K1LuminanceValues.length - 20);
try
{
t = new JPEGQTable(smallTable);
}
catch (IllegalArgumentException e)
{
constructionFailed = true;
}
h.check(constructionFailed);
// table has length greater than 64
constructionFailed = false;
int[] bigTable = new int[K1LuminanceValues.length + 20];
System.arraycopy(K1LuminanceValues, 0, bigTable, 0, K1LuminanceValues.length);
try
{
t = new JPEGQTable(bigTable);
}
catch (IllegalArgumentException e)
{
constructionFailed = true;
}