package lesson4;
import org.junit.Assert;
import org.junit.Test;
import webapp.WebAppException;
import java.util.Arrays;
/**
* User: gkislin
* Date: 18.04.2014
*/
public class MinMaxTest {
static Integer[] array;
static String[] arrayString;
static {
array = new Integer[]{2, 4, 7, 1, 4, 9, 123, -5};
arrayString = new String[]{"2", "4", "7", "1", "4", "9", "123", "-5"};
}
@Test
public void testToString() throws Exception {
System.out.println(Arrays.toString(array));
}
@Test
public void testStaticCalculate() throws Exception {
MinMaxStatic.Pair<Integer> p = MinMaxStatic.calculate(array);
System.out.println(p);
Assert.assertEquals(new MinMaxStatic.Pair<>(-5, 123), p);
MinMaxStatic.Pair<String> p2 = MinMaxStatic.calculate(arrayString);
System.out.println(p2);
Assert.assertEquals(new MinMaxStatic.Pair<>("-5", "9"), p2);
}
@Test
public void testCalculate() throws Exception {
MinMax.Pair p = new MinMax<>(array).calculate();
System.out.println(p);
Assert.assertEquals(new MinMax<Integer>(null).new Pair(-5, 123), p);
MinMax.Pair p2 = new MinMax<>(arrayString).calculate();
System.out.println(p2);
Assert.assertEquals(new MinMax<String>(null).new Pair("-5", "9"), p2);
}
@Test(expected = WebAppException.class)
public void testException() throws Exception {
throw new WebAppException("test");
}
}