// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java
// public static int clamp(int i, int min, int max) {
// 	return Math.min(max, Math.max(i, min));
// }
// 
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java
// public static double linearConvert(double v, double from1, double from2, double to1, double to2) {
// 	final double fromRange = from2 - from1;
// 	final double toRange = to2 - to1;
// 	final double quotient = (v-from1)/fromRange;
// 	return (quotient * toRange) + to1;
// }


import static com.iamcontent.core.math.MathUtils.clamp;
import static com.iamcontent.core.math.MathUtils.linearConvert;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
  IAmContent Public Libraries.
  Copyright (C) 2015-2021 Greg Elderfield
  @author Greg Elderfield, support@jarchitect.co.uk
 
  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU General Public License as published by the Free Software Foundation; either version 2 of 
  the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with this program;
  if not, write to the Free Software Foundation, Inc., 
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package com.iamcontent.core.math;



public class MathUtilsTest {

	private static final double TOLERANCE = 0.000001;
	
	@Test
	public void testClamp_int() {
		checkIntClamp1to3(1, 0);
		checkIntClamp1to3(1, 1);
		checkIntClamp1to3(2, 2);
		checkIntClamp1to3(3, 3);
		checkIntClamp1to3(3, 4);
	}

	private void checkIntClamp1to3(int expected, int in) {

// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java
// public static int clamp(int i, int min, int max) {
// 	return Math.min(max, Math.max(i, min));
// }
// 
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MathUtils.java
// public static double linearConvert(double v, double from1, double from2, double to1, double to2) {
// 	final double fromRange = from2 - from1;
// 	final double toRange = to2 - to1;
// 	final double quotient = (v-from1)/fromRange;
// 	return (quotient * toRange) + to1;
// }


// Path: public-java/iamcontent-core/src/test/java/com/iamcontent/core/math/MathUtilsTest.java
import static com.iamcontent.core.math.MathUtils.clamp;
import static com.iamcontent.core.math.MathUtils.linearConvert;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
  IAmContent Public Libraries.
  Copyright (C) 2015-2021 Greg Elderfield
  @author Greg Elderfield, support@jarchitect.co.uk
 
  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU General Public License as published by the Free Software Foundation; either version 2 of 
  the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with this program;
  if not, write to the Free Software Foundation, Inc., 
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package com.iamcontent.core.math;



public class MathUtilsTest {

	private static final double TOLERANCE = 0.000001;
	
	@Test
	public void testClamp_int() {
		checkIntClamp1to3(1, 0);
		checkIntClamp1to3(1, 1);
		checkIntClamp1to3(2, 2);
		checkIntClamp1to3(3, 3);
		checkIntClamp1to3(3, 4);
	}

	private void checkIntClamp1to3(int expected, int in) {

		assertEquals(expected, clamp(in, 1, 3));
