本文整理了Java中org.assertj.core.data.Offset
类的一些代码示例,展示了Offset
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Offset
类的具体详情如下:
包路径:org.assertj.core.data.Offset
类名称:Offset
[英]A positive offset.
[中]正偏移量。
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for float {@link Offset}.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(0.2f).isCloseTo(0.0f, offset(0.2f));</code></pre>
* @param value the allowed offset
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Float> offset(Float value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Long {@link Offset} to use with strict {@link AbstractLongAssert#isCloseTo(long, Offset) isCloseTo} assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(5l).isCloseTo(7l, byLessThan(3l));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Long> byLessThan(Long value) {
return Offset.strictOffset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Creates a new {@link Offset} that let {@code isCloseTo} assertions pass when {@code |actual-expected| <= offset value}.
* <p>
* Example:
* <pre><code class='java'> // assertions succeed
* assertThat(8.1).isCloseTo(8.0, offset(0.2));
* assertThat(8.1).isCloseTo(8.0, offset(0.1));
*
* // assertion fails
* assertThat(8.1).isCloseTo(8.0, offset(0.01));</code></pre>
*
* @param <T> the type of value of the {@link Offset}.
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static <T extends Number> Offset<T> offset(T value) {
checkNotNull(value);
checkArgument(value.doubleValue() >= 0d, "An offset value should be greater than or equal to zero");
return new Offset<>(value, false);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Creates a new strict {@link Offset} that let {@code isCloseTo} assertion pass when {@code |actual-expected| < offset value}.
* <p>
* Examples:
* <pre><code class='java'> // assertion succeeds
* assertThat(8.1).isCloseTo(8.0, offset(0.2));
*
* // assertions fail
* assertThat(8.1).isCloseTo(8.0, offset(0.1));
* assertThat(8.1).isCloseTo(8.0, offset(0.01));</code></pre>
*
* @param <T> the type of value of the {@link Offset}.
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static <T extends Number> Offset<T> strictOffset(T value) {
checkNotNull(value);
checkArgument(value.doubleValue() > 0d, "A strict offset value should be greater than zero");
return new Offset<>(value, true);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Byte {@link Offset} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat((byte) 10).isCloseTo((byte) 11, byLessThan((byte) 1));</code></pre>
*
* @param value the allowed offset
* @return the created {@code Offset}.
*/
public static Offset<Byte> byLessThan(Byte value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for BigInteger {@link Offset} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(BigInteger.TEN).isCloseTo(new BigInteger("11"), byLessThan(new BigInteger("2")));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
* @since 2.7.0 / 3.7.0
*/
public static Offset<BigInteger> byLessThan(BigInteger value) {
return Offset.strictOffset(value);
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Creates a new {@link Offset} that let {@code isCloseTo} assertions pass when {@code |actual-expected| <= offset value}.
* <p>
* Example:
* <pre><code class='java'> // assertions succeed
* assertThat(8.1).isCloseTo(8.0, offset(0.2));
* assertThat(8.1).isCloseTo(8.0, offset(0.1));
*
* // assertion fails
* assertThat(8.1).isCloseTo(8.0, offset(0.01));</code></pre>
*
* @param <T> the type of value of the {@link Offset}.
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static <T extends Number> Offset<T> offset(T value) {
checkNotNull(value);
checkArgument(value.doubleValue() >= 0d, "An offset value should be greater than or equal to zero");
return new Offset<>(value, false);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Alias for {@link #offset(Float)} to use with real number assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(0.2f).isEqualTo(0.0f, withPrecision(0.2f));</code></pre>
* @param value the required precision
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Float> withPrecision(Float value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Byte {@link Offset} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat((byte) 10).isCloseTo((byte) 11, byLessThan((byte) 2));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Byte> byLessThan(Byte value) {
return Offset.strictOffset(value);
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Creates a new strict {@link Offset} that let {@code isCloseTo} assertion pass when {@code |actual-expected| < offset value}.
* <p>
* Examples:
* <pre><code class='java'> // assertion succeeds
* assertThat(8.1).isCloseTo(8.0, offset(0.2));
*
* // assertions fail
* assertThat(8.1).isCloseTo(8.0, offset(0.1));
* assertThat(8.1).isCloseTo(8.0, offset(0.01));</code></pre>
*
* @param <T> the type of value of the {@link Offset}.
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static <T extends Number> Offset<T> strictOffset(T value) {
checkNotNull(value);
checkArgument(value.doubleValue() > 0d, "A strict offset value should be greater than zero");
return new Offset<>(value, true);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Alias for {@link #offset(Float)} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(8.2f).isCloseTo(8.0f, byLessThan(0.2f));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Float> byLessThan(Float value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Long {@link Offset} to use with strict {@link AbstractIntegerAssert#isCloseTo(int, Offset) isCloseTo} assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(10).isCloseTo(12, byLessThan(1));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Integer> byLessThan(Integer value) {
return Offset.strictOffset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Short {@link Offset} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(10).isCloseTo(11, byLessThan(1));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Short> byLessThan(Short value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Alias for {@link #offset(Float)} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(8.2f).isCloseTo(8.0f, byLessThan(0.5f));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Float> byLessThan(Float value) {
return Offset.strictOffset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Alias for {@link #offset(Double)} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(8.1).isCloseTo(8.0, within(0.1));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Double> within(Double value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for BigDecimal {@link Offset} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(BigDecimal.TEN).isCloseTo(new BigDecimal("10.5"), byLessThan(BigDecimal.ONE));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<BigDecimal> byLessThan(BigDecimal value) {
return Offset.strictOffset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for double {@link Offset}.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(0.1).isEqualTo(0.0, offset(0.1));</code></pre>
* @param value the allowed offset
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Double> offset(Double value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Short {@link Offset} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat((short) 10).isCloseTo((short) 11, byLessThan((short) 2));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Short> byLessThan(Short value) {
return Offset.strictOffset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Alias for {@link #offset(Double)} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(0.1).isCloseTo(0.0, within(0.1));</code></pre>
* @param value the allowed offset
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Double> within(Double value) {
return Offset.offset(value);
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Assertions entry point for Long {@link Offset} to use with strict {@link AbstractLongAssert#isCloseTo(long, Offset) isCloseTo} assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(5l).isCloseTo(7l, byLessThan(3l));</code></pre>
*
* @param value the value of the offset.
* @return the created {@code Offset}.
* @throws NullPointerException if the given value is {@code null}.
* @throws IllegalArgumentException if the given value is negative.
*/
public static Offset<Long> byLessThan(Long value) {
return Offset.strictOffset(value);
}
内容来源于网络,如有侵权,请联系作者删除!