/*
 * Zorbage: an algebraic data hierarchy for use in numeric processing.
 *
 * Copyright (C) 2016-2018 Barry DeZonia
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package nom.bdezonia.zorbage.type.data.bigint;

import static org.junit.Assert.assertTrue;

import java.math.BigInteger;

import org.junit.Test;

import nom.bdezonia.zorbage.groups.G;

/**
 * 
 * @author Barry DeZonia
 *
 */
public class TestUnboundedIntGroup {

	@Test
	public void testHugeNumbers() {
		UnboundedIntMember a = new UnboundedIntMember(Long.MAX_VALUE);
		UnboundedIntMember b = new UnboundedIntMember(44);
		UnboundedIntMember product = new UnboundedIntMember();

		G.BIGINT.multiply().call(a,b,product);
		
		assertTrue(new BigInteger("405828369621610135508").equals(product.v()));
	}
}

@@ -1468,24 +1468,69 @@
 ta.bigint;%0A%0A
+import static org.junit.Assert.assertEquals;%0A
 import stati
@@ -1647,16 +1647,244 @@
 age.
-groups.G
+algorithm.MinMaxElement;%0Aimport nom.bdezonia.zorbage.algorithm.Shuffle;%0Aimport nom.bdezonia.zorbage.groups.G;%0Aimport nom.bdezonia.zorbage.type.storage.IndexedDataSource;%0Aimport nom.bdezonia.zorbage.type.storage.array.ArrayStorageGeneric
 ;%0A%0A/
@@ -2298,10 +2298,751 @@
 )));%0A%09%7D%0A
+%09%0A%09@Test%0A%09public void minmax() %7B%0A%09%09IndexedDataSource%3C?, UnboundedIntMember%3E list =%0A%09%09%09%09new ArrayStorageGeneric%3CUnboundedIntGroup,UnboundedIntMember%3E(5000, G.BIGINT);%0A%09%09UnboundedIntMember a = G.BIGINT.construct(%221234567890%22);%0A%09%09UnboundedIntMember b = G.BIGINT.construct(%2255%22);%0A%09%09for (long i = 0, j = list.size()-1; i %3C list.size()/2; i++,j--) %7B%0A%09%09%09list.set(i, a);%0A%09%09%09list.set(j, b);%0A%09%09%09G.BIGINT.pred().call(a, a);%0A%09%09%09G.BIGINT.succ().call(b, b);%0A%09%09%7D%0A%09%09Shuffle.compute(G.BIGINT, list);%0A%09%09UnboundedIntMember min = G.BIGINT.construct();%0A%09%09UnboundedIntMember max = G.BIGINT.construct();%0A%09%09MinMaxElement.compute(G.BIGINT, list, min, max);%0A%09%09assertEquals(BigInteger.valueOf(55), min.v());%0A%09%09assertEquals(BigInteger.valueOf(1234567890), max.v());%0A%09%7D%0A
 %7D%0A

Test the fact that we can find bounds of lists of unbounded ints