/*-
 * #%L
 * Image processing operations for SciJava Ops.
 * %%
 * Copyright (C) 2014 - 2024 SciJava developers.
 * %%
 * 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%
 */
/*
 * This is autogenerated source code -- DO NOT EDIT. Instead, edit the
 * corresponding template in templates/ and rerun bin/generate.groovy.
 */

package org.scijava.ops.image.convert;

import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.array.ArrayImgs;
import net.imglib2.loops.LoopBuilder;
import net.imglib2.type.logic.BitType;
import net.imglib2.type.numeric.complex.ComplexDoubleType;
import net.imglib2.type.numeric.complex.ComplexFloatType;
import net.imglib2.type.numeric.integer.*;
import net.imglib2.type.numeric.real.DoubleType;
import net.imglib2.type.numeric.real.FloatType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.scijava.ops.image.AbstractOpTest;

public class RAIConvertersTest extends AbstractOpTest {

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.BitType', type='Computer'
	 */
	public static void computeBitType(RandomAccessibleInterval<BitType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertBitTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.BitType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.Unsigned2BitType', type='Computer'
	 */
	public static void computeUnsigned2BitType(RandomAccessibleInterval<Unsigned2BitType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertUnsigned2BitTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.Unsigned2BitType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.Unsigned4BitType', type='Computer'
	 */
	public static void computeUnsigned4BitType(RandomAccessibleInterval<Unsigned4BitType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertUnsigned4BitTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.Unsigned4BitType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.UnsignedByteType', type='Computer'
	 */
	public static void computeUnsignedByteType(RandomAccessibleInterval<UnsignedByteType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertUnsignedByteTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.UnsignedByteType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.ByteType', type='Computer'
	 */
	public static void computeByteType(RandomAccessibleInterval<ByteType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertByteTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.ByteType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.UnsignedShortType', type='Computer'
	 */
	public static void computeUnsignedShortType(RandomAccessibleInterval<UnsignedShortType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertUnsignedShortTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.UnsignedShortType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.ShortType', type='Computer'
	 */
	public static void computeShortType(RandomAccessibleInterval<ShortType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertShortTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.ShortType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.Unsigned12BitType', type='Computer'
	 */
	public static void computeUnsigned12BitType(RandomAccessibleInterval<Unsigned12BitType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertUnsigned12BitTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.Unsigned12BitType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.UnsignedIntType', type='Computer'
	 */
	public static void computeUnsignedIntType(RandomAccessibleInterval<UnsignedIntType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertUnsignedIntTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.UnsignedIntType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.IntType', type='Computer'
	 */
	public static void computeIntType(RandomAccessibleInterval<IntType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertIntTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.IntType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.UnsignedLongType', type='Computer'
	 */
	public static void computeUnsignedLongType(RandomAccessibleInterval<UnsignedLongType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertUnsignedLongTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.UnsignedLongType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.LongType', type='Computer'
	 */
	public static void computeLongType(RandomAccessibleInterval<LongType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertLongTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.LongType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.Unsigned128BitType', type='Computer'
	 */
	public static void computeUnsigned128BitType(RandomAccessibleInterval<Unsigned128BitType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertUnsigned128BitTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.Unsigned128BitType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.FloatType', type='Computer'
	 */
	public static void computeFloatType(RandomAccessibleInterval<FloatType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertFloatTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.FloatType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

	/**
	 * @param out the output image
	 * @implNote op names='test.convert.image.DoubleType', type='Computer'
	 */
	public static void computeDoubleType(RandomAccessibleInterval<DoubleType> out) {
		LoopBuilder.setImages(out).forEachPixel(o -> o.setReal(1.0));
	}

	@Test
	public void testConvertDoubleTypeImage() {
		var out = ArrayImgs.doubles(1, 1);
		out.firstElement().set(0.0);
		ops.op("test.convert.image.DoubleType").output(out).compute();
		double expected = 1.0;
		double actual = out.firstElement().get();
		Assertions.assertEquals(expected, actual);
	}

}
