package algorithms;

import org.junit.Test;

import junit.framework.Assert;
import utils.EventAnalyzer;

public class MaxPairwiseProductTest {
	@Test
	public void testZero() throws Exception {
		int[] numbers = { 0 };

		long actual = MaxPairwiseProduct.getMaxPairwiseProduct(numbers);

		Assert.assertEquals(0, actual);
	}

	@Test
	public void testOne() throws Exception {
		int[] numbers = { 1 };

		long actual = MaxPairwiseProduct.getMaxPairwiseProduct(numbers);

		Assert.assertEquals(0, actual);
	}

	@Test
	public void testTwo() throws Exception {
		int[] numbers = { 1, 2 };

		long actual = MaxPairwiseProduct.getMaxPairwiseProduct(numbers);

		Assert.assertEquals(2, actual);
	}

	@Test
	public void testWithHugeIntegers() throws Exception {
		int[] numbers = { 2000000000, 2000000000 };

		long actual = MaxPairwiseProduct.getMaxPairwiseProduct(numbers);

		Assert.assertTrue("Result must be a huge positive value", actual > 0);
	}

	@Test
	public void testTree() throws Exception {
		int[] numbers = { 1, 2, 3 };

		long actual = MaxPairwiseProduct.getMaxPairwiseProduct(numbers);

		Assert.assertEquals(6, actual);
	}

	@Test
	public void testFour() throws Exception {
		int[] numbers = { 1, 2, 3, 4 };

		long actual = MaxPairwiseProduct.getMaxPairwiseProduct(numbers);

		Assert.assertEquals(12, actual);
	}

	@Test
	public void testUnorderedFour() throws Exception {
		int[] numbers = { 1, 2, 3, 2 };

		long actual = MaxPairwiseProduct.getMaxPairwiseProduct(numbers);

		Assert.assertEquals(6, actual);
	}

	@Test
	public void testBigArray() throws Exception {
		int[] numbers = new int[20000000];
		EventAnalyzer eventAnalyzer = new EventAnalyzer();

		eventAnalyzer.before();
		long actual = MaxPairwiseProduct.getMaxPairwiseProduct(numbers);
		eventAnalyzer.after();

		eventAnalyzer.report();
		Assert.assertEquals(0, actual);
	}
}

@@ -1843,11 +1843,221 @@
 ual);%0A%09%7D
+%0A%0A%09@Test%0A%09public void testCollectionWithTwoFours() throws Exception %7B%0A%09%09int%5B%5D numbers = %7B 1, 4, 3, 4 %7D;%0A%0A%09%09long actual = MaxPairwiseProduct.getMaxPairwiseProduct(numbers);%0A%0A%09%09Assert.assertEquals(16, actual);%0A%09%7D
 %0A%7D%0A

Test for duplicated values