/*
 * #%L
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2014 - 2016 Board of Regents of the University of
 * Wisconsin-Madison, University of Konstanz and Brian Northan.
 * %%
 * 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.
 * #L%
 */

package net.imagej.ops.create;

import static org.junit.Assert.assertEquals;

import net.imagej.ops.AbstractOpTest;
import net.imglib2.type.logic.BitType;
import net.imglib2.type.numeric.integer.ByteType;
import net.imglib2.type.numeric.integer.IntType;
import net.imglib2.type.numeric.integer.LongType;
import net.imglib2.type.numeric.integer.ShortType;
import net.imglib2.type.numeric.integer.UnsignedByteType;
import net.imglib2.type.numeric.integer.UnsignedIntType;
import net.imglib2.type.numeric.integer.UnsignedShortType;

import org.junit.Test;

/**
 * Tests several ways to create an IntegerType.
 *
 * @author Christian Dietz (University of Konstanz)
 */
public class CreateIntegerTypeTest extends AbstractOpTest {

	@Test
	public void testUint1() {
		assertEquals(BitType.class, ops.create().integerType(1).getClass());
	}

	@Test
	public void testInt8() {
		assertEquals(ByteType.class, ops.create().integerType(Byte.MAX_VALUE)
			.getClass());
	}

	@Test
	public void testUint8() {
		assertEquals(UnsignedByteType.class, ops.create().integerType(
			Byte.MAX_VALUE * 2 + 1).getClass());
	}

	@Test
	public void testInt16() {
		assertEquals(ShortType.class, ops.create().integerType(Short.MAX_VALUE)
			.getClass());
	}

	@Test
	public void testUint16() {
		assertEquals(UnsignedShortType.class, ops.create().integerType(
			Short.MAX_VALUE * 2 + 1).getClass());
	}

	@Test
	public void testInt32() {
		assertEquals(IntType.class, ops.create().integerType(Integer.MAX_VALUE)
			.getClass());
	}

	@Test
	public void testUint32() {
		assertEquals(UnsignedIntType.class, ops.create().integerType(
			Integer.MAX_VALUE * 2l + 1).getClass());
	}

	@Test
	public void testInt64() {
		assertEquals(LongType.class, ops.create().integerType(Long.MAX_VALUE)
			.getClass());
	}
}

@@ -2302,22 +2302,20 @@
 %09%09assert
-Equals
+Type
 (BitType
@@ -2326,46 +2326,9 @@
 ss, 
-ops.create().integerType(1).getClass()
+1
 );%0A%09
@@ -2371,22 +2371,20 @@
 %09%09assert
-Equals
+Type
 (ByteTyp
@@ -2396,63 +2396,22 @@
 ss, 
-ops.create().integerType(Byte.MAX_VALUE)%0A%09%09%09.getClass()
+Byte.MAX_VALUE
 );%0A%09
@@ -2447,38 +2447,36 @@
 nt8() %7B%0A%09%09assert
-Equals
+Type
 (UnsignedByteTyp
@@ -2488,37 +2488,8 @@
 ss, 
-ops.create().integerType(%0A%09%09%09
 Byte
@@ -2503,36 +2503,24 @@
 LUE * 2 + 1)
-.getClass())
 ;%0A%09%7D%0A%0A%09@Test
@@ -2555,22 +2555,20 @@
 %09%09assert
-Equals
+Type
 (ShortTy
@@ -2581,64 +2581,23 @@
 ss, 
-ops.create().integerType(Short.MAX_VALUE)%0A%09%09%09.getClass()
+Short.MAX_VALUE
 );%0A%09
@@ -2634,38 +2634,36 @@
 t16() %7B%0A%09%09assert
-Equals
+Type
 (UnsignedShortTy
@@ -2676,37 +2676,8 @@
 ss, 
-ops.create().integerType(%0A%09%09%09
 Shor
@@ -2692,36 +2692,24 @@
 LUE * 2 + 1)
-.getClass())
 ;%0A%09%7D%0A%0A%09@Test
@@ -2744,22 +2744,20 @@
 %09%09assert
-Equals
+Type
 (IntType
@@ -2768,33 +2768,8 @@
 ss, 
-ops.create().integerType(
 Inte
@@ -2782,32 +2782,16 @@
 X_VALUE)
-%0A%09%09%09.getClass())
 ;%0A%09%7D%0A%0A%09@
@@ -2831,22 +2831,20 @@
 %09%09assert
-Equals
+Type
 (Unsigne
@@ -2863,37 +2863,8 @@
 ss, 
-ops.create().integerType(%0A%09%09%09
 Inte
@@ -2886,28 +2886,16 @@
  2l + 1)
-.getClass())
 ;%0A%09%7D%0A%0A%09@
@@ -2934,22 +2934,20 @@
 %09%09assert
-Equals
+Type
 (LongTyp
@@ -2954,16 +2954,148 @@
 e.class,
+ Long.MAX_VALUE);%0A%09%7D%0A%0A%09// -- Helper methods --%0A%0A%09private void assertType(final Class%3C?%3E type, final long max) %7B%0A%09%09assertEquals(type,
  ops.cre
@@ -3116,27 +3116,12 @@
 ype(
-Long.MAX_VALUE)%0A%09%09%09
+max)
 .get
@@ -3133,10 +3133,11 @@
 ());%0A%09%7D%0A
+%0A
 %7D%0A

refactor to a common method