本文整理了Java中org.assertj.core.data.Offset.offset()
方法的一些代码示例,展示了Offset.offset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Offset.offset()
方法的具体详情如下:
包路径:org.assertj.core.data.Offset
类名称:Offset
方法名:offset
[英]Creates a new 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 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
/**
* 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
/**
* 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 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(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 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
/**
* 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: org.assertj/assertj-core
/**
* Alias for {@link #offset(Double)} to use with real number assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(0.1).isEqualTo(0.0, withPrecision(0.1));</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<Double> withPrecision(Double value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for float {@link Offset}.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(8.2f).isCloseTo(8.0f, offset(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> offset(Float value) {
return Offset.offset(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 Short {@link Offset} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(10).isCloseTo(11, within(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> within(Short value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Integer {@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<Integer> byLessThan(Integer value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Long {@link Offset} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(5l).isCloseTo(7l, byLessThan(2l));</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.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Integer {@link Offset} to use with isCloseTo assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(10).isCloseTo(11, within(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> within(Integer value) {
return Offset.offset(value);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Assertions entry point for Long {@link Offset} to use with {@link AbstractLongAssert#isCloseTo(long, Offset) isCloseTo} assertions.
* <p>
* Typical usage :
* <pre><code class='java'> assertThat(5l).isCloseTo(7l, within(2l));</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<Long> within(Long value) {
return Offset.offset(value);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void test_get_double() {
Settings settings = new MapSettings();
settings.setProperty("from_double", 3.14159);
settings.setProperty("from_string", "3.14159");
assertThat(settings.getDouble("from_double")).isEqualTo(3.14159, Offset.offset(0.00001));
assertThat(settings.getDouble("from_string")).isEqualTo(3.14159, Offset.offset(0.00001));
assertThat(settings.getDouble("unknown")).isNull();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void test_get_float() {
Settings settings = new MapSettings();
settings.setProperty("from_float", 3.14159f);
settings.setProperty("from_string", "3.14159");
assertThat(settings.getDouble("from_float")).isEqualTo(3.14159f, Offset.offset(0.00001));
assertThat(settings.getDouble("from_string")).isEqualTo(3.14159f, Offset.offset(0.00001));
assertThat(settings.getDouble("unknown")).isNull();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void toMeasure_should_not_loose_decimals_of_float_values() {
MetricImpl metric = new MetricImpl(42, "double", "name", Metric.MetricType.FLOAT, 5, null, false);
MeasureDto measureDto = new MeasureDto()
.setValue(0.12345);
Optional<Measure> measure = underTest.toMeasure(measureDto, metric);
assertThat(measure.get().getDoubleValue()).isEqualTo(0.12345, Offset.offset(0.000001));
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void toMeasure_should_not_loose_decimals_of_float_values() {
MetricImpl metric = new MetricImpl(42, "double", "name", Metric.MetricType.FLOAT, 5, null, false);
LiveMeasureDto LiveMeasureDto = new LiveMeasureDto()
.setValue(0.12345);
Optional<Measure> measure = underTest.toMeasure(LiveMeasureDto, metric);
assertThat(measure.get().getDoubleValue()).isEqualTo(0.12345, Offset.offset(0.000001));
}
}
内容来源于网络,如有侵权,请联系作者删除!