Tabnine Logo
BigDecimalCloseTo
Code IndexAdd Tabnine to your IDE (free)

How to use
BigDecimalCloseTo
in
org.hamcrest.number

Best Java code snippets using org.hamcrest.number.BigDecimalCloseTo (Showing top 20 results out of 315)

origin: org.hamcrest/hamcrest-all

/**
 * Creates a matcher of {@link java.math.BigDecimal}s that matches when an examined BigDecimal is equal
 * to the specified <code>operand</code>, within a range of +/- <code>error</code>. The comparison for equality
 * is done by BigDecimals {@link java.math.BigDecimal#compareTo(java.math.BigDecimal)} method.
 * <p/>
 * For example:
 * <pre>assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))</pre>
 * 
 * @param operand
 *     the expected value of matching BigDecimals
 * @param error
 *     the delta (+/-) within which matches will be allowed
 */
public static org.hamcrest.Matcher<java.math.BigDecimal> closeTo(java.math.BigDecimal operand, java.math.BigDecimal error) {
 return org.hamcrest.number.BigDecimalCloseTo.closeTo(operand, error);
}
origin: hamcrest/JavaHamcrest

/**
 * Creates a matcher of {@link java.math.BigDecimal}s that matches when an examined BigDecimal is equal
 * to the specified <code>operand</code>, within a range of +/- <code>error</code>. The comparison for equality
 * is done by BigDecimals {@link java.math.BigDecimal#compareTo(java.math.BigDecimal)} method.
 * For example:
 * <pre>assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))</pre>
 * 
 * @param operand
 *     the expected value of matching BigDecimals
 * @param error
 *     the delta (+/-) within which matches will be allowed
 */
public static Matcher<BigDecimal> closeTo(BigDecimal operand, BigDecimal error) {
  return new BigDecimalCloseTo(operand, error);
}
origin: org.hamcrest/hamcrest-all

@Override
public boolean matchesSafely(BigDecimal item) {
  return actualDelta(item).compareTo(BigDecimal.ZERO) <= 0;
}
origin: hamcrest/JavaHamcrest

/**
 * Creates a matcher of {@link java.math.BigDecimal}s that matches when an examined BigDecimal is equal
 * to the specified <code>operand</code>, within a range of +/- <code>error</code>. The comparison for equality
 * is done by BigDecimals {@link java.math.BigDecimal#compareTo(java.math.BigDecimal)} method.
 * For example:
 * <pre>assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))</pre>
 * 
 * @param operand
 *     the expected value of matching BigDecimals
 * @param error
 *     the delta (+/-) within which matches will be allowed
 */
public static org.hamcrest.Matcher<java.math.BigDecimal> closeTo(java.math.BigDecimal operand, java.math.BigDecimal error) {
 return org.hamcrest.number.BigDecimalCloseTo.closeTo(operand, error);
}
origin: hamcrest/JavaHamcrest

@Override
public boolean matchesSafely(BigDecimal item) {
  return actualDelta(item).compareTo(BigDecimal.ZERO) <= 0;
}
origin: org.hamcrest/hamcrest-all

/**
 * Creates a matcher of {@link java.math.BigDecimal}s that matches when an examined BigDecimal is equal
 * to the specified <code>operand</code>, within a range of +/- <code>error</code>. The comparison for equality
 * is done by BigDecimals {@link java.math.BigDecimal#compareTo(java.math.BigDecimal)} method.
 * <p/>
 * For example:
 * <pre>assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))</pre>
 * 
 * @param operand
 *     the expected value of matching BigDecimals
 * @param error
 *     the delta (+/-) within which matches will be allowed
 */
@Factory
public static Matcher<BigDecimal> closeTo(BigDecimal operand, BigDecimal error) {
  return new BigDecimalCloseTo(operand, error);
}
origin: hamcrest/JavaHamcrest

@Override
protected Matcher<?> createMatcher() {
 BigDecimal irrelevant = new BigDecimal("0.01");
 return closeTo(irrelevant, irrelevant);
}

origin: org.hamcrest/hamcrest-all

@Override
public void describeMismatchSafely(BigDecimal item, Description mismatchDescription) {
  mismatchDescription.appendValue(item)
      .appendText(" differed by ")
      .appendValue(actualDelta(item));
}
origin: org.hamcrest/java-hamcrest

/**
 * Creates a matcher of {@link java.math.BigDecimal}s that matches when an examined BigDecimal is equal
 * to the specified <code>operand</code>, within a range of +/- <code>error</code>. The comparison for equality
 * is done by BigDecimals {@link java.math.BigDecimal#compareTo(java.math.BigDecimal)} method.
 * For example:
 * <pre>assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))</pre>
 * 
 * @param operand
 *     the expected value of matching BigDecimals
 * @param error
 *     the delta (+/-) within which matches will be allowed
 */
public static Matcher<BigDecimal> closeTo(BigDecimal operand, BigDecimal error) {
  return new BigDecimalCloseTo(operand, error);
}
origin: org.hamcrest/java-hamcrest

/**
 * Creates a matcher of {@link java.math.BigDecimal}s that matches when an examined BigDecimal is equal
 * to the specified <code>operand</code>, within a range of +/- <code>error</code>. The comparison for equality
 * is done by BigDecimals {@link java.math.BigDecimal#compareTo(java.math.BigDecimal)} method.
 * For example:
 * <pre>assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))</pre>
 * 
 * @param operand
 *     the expected value of matching BigDecimals
 * @param error
 *     the delta (+/-) within which matches will be allowed
 */
public static org.hamcrest.Matcher<java.math.BigDecimal> closeTo(java.math.BigDecimal operand, java.math.BigDecimal error) {
 return org.hamcrest.number.BigDecimalCloseTo.closeTo(operand, error);
}
origin: hamcrest/JavaHamcrest

@Override
public void describeMismatchSafely(BigDecimal item, Description mismatchDescription) {
  mismatchDescription.appendValue(item)
      .appendText(" differed by ")
      .appendValue(actualDelta(item))
      .appendText(" more than delta ")
      .appendValue(delta);
}
origin: org.hamcrest/hamcrest

/**
 * Creates a matcher of {@link java.math.BigDecimal}s that matches when an examined BigDecimal is equal
 * to the specified <code>operand</code>, within a range of +/- <code>error</code>. The comparison for equality
 * is done by BigDecimals {@link java.math.BigDecimal#compareTo(java.math.BigDecimal)} method.
 * For example:
 * <pre>assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))</pre>
 * 
 * @param operand
 *     the expected value of matching BigDecimals
 * @param error
 *     the delta (+/-) within which matches will be allowed
 */
public static Matcher<BigDecimal> closeTo(BigDecimal operand, BigDecimal error) {
  return new BigDecimalCloseTo(operand, error);
}
origin: org.hamcrest/hamcrest

/**
 * Creates a matcher of {@link java.math.BigDecimal}s that matches when an examined BigDecimal is equal
 * to the specified <code>operand</code>, within a range of +/- <code>error</code>. The comparison for equality
 * is done by BigDecimals {@link java.math.BigDecimal#compareTo(java.math.BigDecimal)} method.
 * For example:
 * <pre>assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))</pre>
 * 
 * @param operand
 *     the expected value of matching BigDecimals
 * @param error
 *     the delta (+/-) within which matches will be allowed
 */
public static org.hamcrest.Matcher<java.math.BigDecimal> closeTo(java.math.BigDecimal operand, java.math.BigDecimal error) {
 return org.hamcrest.number.BigDecimalCloseTo.closeTo(operand, error);
}
origin: org.hamcrest/java-hamcrest

@Override
public boolean matchesSafely(BigDecimal item) {
  return actualDelta(item).compareTo(BigDecimal.ZERO) <= 0;
}
origin: kousen/Spring-Framework-Essentials

@Test
public void testDeposit() throws Exception {
  BigDecimal start = service.getBalance(1L);
  BigDecimal amount = new BigDecimal("50.0");
  service.deposit(1L, amount);
  BigDecimal finish = start.add(amount);
  assertThat(finish, is(closeTo(service.getBalance(1L),
      new BigDecimal("0.01"))));
}
origin: org.hamcrest/java-hamcrest

@Override
public void describeMismatchSafely(BigDecimal item, Description mismatchDescription) {
  mismatchDescription.appendValue(item)
      .appendText(" differed by ")
      .appendValue(actualDelta(item))
      .appendText(" more than delta ")
      .appendValue(delta);
}
origin: kousen/Spring-Framework-Essentials

@Test
public void testWithdraw() throws Exception {
  BigDecimal start = service.getBalance(1L);
  BigDecimal amount = new BigDecimal("50.0");
  service.withdraw(1L, amount);
  BigDecimal finish = start.subtract(amount);
  assertThat(finish, is(closeTo(service.getBalance(1L),
      new BigDecimal("0.01"))));
}
origin: org.hamcrest/hamcrest

@Override
public boolean matchesSafely(BigDecimal item) {
  return actualDelta(item).compareTo(BigDecimal.ZERO) <= 0;
}
origin: kousen/Spring-Framework-Essentials

  @Test
  public void testTransfer() throws Exception {
    BigDecimal acct1start = service.getBalance(1L);
    BigDecimal acct2start = service.getBalance(2L);

    BigDecimal amount = new BigDecimal("50.0");
    service.transfer(1L, 2L, amount);

    BigDecimal acct1finish = acct1start.subtract(amount);
    BigDecimal acct2finish = acct2start.add(amount);

    assertThat(acct1finish, is(closeTo(service.getBalance(1L),
        new BigDecimal("0.01"))));
    assertThat(acct2finish, is(closeTo(service.getBalance(2L),
        new BigDecimal("0.01"))));
  }
}
origin: org.hamcrest/hamcrest

@Override
public void describeMismatchSafely(BigDecimal item, Description mismatchDescription) {
  mismatchDescription.appendValue(item)
      .appendText(" differed by ")
      .appendValue(actualDelta(item))
      .appendText(" more than delta ")
      .appendValue(delta);
}
org.hamcrest.numberBigDecimalCloseTo

Most used methods

  • closeTo
    Creates a matcher of java.math.BigDecimals that matches when an examined BigDecimal is equal to the
  • <init>
  • actualDelta

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • getResourceAsStream (ClassLoader)
  • getExternalFilesDir (Context)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now