Package com.wesleyhome.math.equation

Source Code of com.wesleyhome.math.equation.AbsoluteValueFunctionTest

package com.wesleyhome.math.equation;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.wesleyhome.math.equation.AbsoluteValueFunction;
import com.wesleyhome.math.equation.SmartNumber;

@RunWith(Parameterized.class)
public class AbsoluteValueFunctionTest {
  private final Number value;

  @Parameters
  public static List<Object[]> data() throws Exception {
    return Arrays.asList(new Object[][] {
      {
        -25
      }, {
        25
      }, {
        -25.2
      }, {
        25.2
      }
    });
  }

  public AbsoluteValueFunctionTest(final Number value) {
    this.value = value;
  }
  private AbsoluteValueFunction function;

  @Before
  public void setUp() throws Exception {
    function = new AbsoluteValueFunction();
  }

  @Test
  public void testEvaluate() throws Exception {
    Number evaluate = function.evaluate(value, null);
    assertThat(evaluate, is(equalTo(SmartNumber.eq(value).absoluteValue())));
  }
}
TOP

Related Classes of com.wesleyhome.math.equation.AbsoluteValueFunctionTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.