mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
@@ -84,6 +84,8 @@ fun <T : BigDecimal> Expect<T?>.toEqual(expected: Nothing?): Expect<T?> =
|
||||
* ```
|
||||
* However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use [notToEqualIncludingScale].
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.BigDecimalExpectationSamples.notToEqual
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -113,6 +115,8 @@ fun <T : BigDecimal> Expect<T>.notToEqual(expected: T): Nothing =
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.BigDecimalExpectationSamples.toEqualNumerically
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <T : BigDecimal> Expect<T>.toEqualNumerically(expected: T): Expect<T> =
|
||||
@@ -132,6 +136,8 @@ fun <T : BigDecimal> Expect<T>.toEqualNumerically(expected: T): Expect<T> =
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.BigDecimalExpectationSamples.notToEqualNumerically
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <T : BigDecimal> Expect<T>.notToEqualNumerically(expected: T): Expect<T> =
|
||||
@@ -148,6 +154,8 @@ fun <T : BigDecimal> Expect<T>.notToEqualNumerically(expected: T): Expect<T> =
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.BigDecimalExpectationSamples.toEqualIncludingScale
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <T : BigDecimal> Expect<T>.toEqualIncludingScale(expected: T): Expect<T> =
|
||||
@@ -164,6 +172,8 @@ fun <T : BigDecimal> Expect<T>.toEqualIncludingScale(expected: T): Expect<T> =
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.BigDecimalExpectationSamples.notToEqualIncludingScale
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <T : BigDecimal> Expect<T>.notToEqualIncludingScale(expected: T): Expect<T> =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB.samples
|
||||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.*
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import java.math.BigDecimal
|
||||
import kotlin.test.Test
|
||||
@@ -12,4 +12,68 @@ class BigDecimalExpectationSamples {
|
||||
// only use toEqual to check against null, otherwise use toEqualNumerically or toEqualIncludingScale
|
||||
expect(null as BigDecimal?).toEqual(null)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun notToEqual() {
|
||||
// only use notToEqual to check against null, otherwise use notToEqualNumerically or notToEqualIncludingScale
|
||||
expect(null as BigDecimal?).notToEqual(BigDecimal("-12345.6789"))
|
||||
expect(null as BigDecimal?).notToEqual(BigDecimal("1.0"))
|
||||
expect(null as BigDecimal?).notToEqual(BigDecimal("25.0"))
|
||||
|
||||
|
||||
expect(null as BigDecimal?).notToEqual(BigDecimal(-12345.6789))
|
||||
expect(null as BigDecimal?).notToEqual(BigDecimal(1.0))
|
||||
expect(null as BigDecimal?).notToEqual(BigDecimal(25.0))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun toEqualNumerically() {
|
||||
expect(BigDecimal("10")).toEqualNumerically(BigDecimal("10.0"))
|
||||
expect(BigDecimal("1213669989183")).toEqualNumerically(BigDecimal("1213669989183"))
|
||||
expect(BigDecimal("1238126387123")).toEqualNumerically(BigDecimal("1238126387123"))
|
||||
|
||||
|
||||
expect(BigDecimal(10)).toEqualNumerically(BigDecimal(10.0))
|
||||
expect(BigDecimal(1213669989183)).toEqualNumerically(BigDecimal(1213669989183))
|
||||
expect(BigDecimal(1238126387123)).toEqualNumerically(BigDecimal(1238126387123))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun notToEqualNumerically() {
|
||||
expect(BigDecimal("10")).notToEqualNumerically(BigDecimal("1213669989183"))
|
||||
expect(BigDecimal("1213669989183")).notToEqualNumerically(BigDecimal("10"))
|
||||
expect(BigDecimal("1238126387123")).notToEqualNumerically(BigDecimal("-1.0"))
|
||||
|
||||
expect(BigDecimal(10)).notToEqualNumerically(BigDecimal(1213669989183))
|
||||
expect(BigDecimal(1213669989183)).notToEqualNumerically(BigDecimal(10))
|
||||
expect(BigDecimal(1238126387123)).notToEqualNumerically(BigDecimal(-1.0))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun toEqualIncludingScale() {
|
||||
expect(BigDecimal("10.0")).toEqualIncludingScale(BigDecimal("10.0"))
|
||||
expect(BigDecimal("456.0")).toEqualIncludingScale(BigDecimal("456.0"))
|
||||
expect(BigDecimal("-1.456")).toEqualIncludingScale(BigDecimal("-1.456"))
|
||||
|
||||
expect(BigDecimal(10.0)).toEqualIncludingScale(BigDecimal(10.0))
|
||||
expect(BigDecimal(456.0)).toEqualIncludingScale(BigDecimal(456.0))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun notToEqualIncludingScale() {
|
||||
expect(BigDecimal("10")).notToEqualIncludingScale(BigDecimal("10.0"))
|
||||
expect(BigDecimal("456.0")).notToEqualIncludingScale(BigDecimal("456"))
|
||||
expect(BigDecimal("-1.456")).notToEqualIncludingScale(BigDecimal("-1.45"))
|
||||
|
||||
expect(BigDecimal(10)).notToEqualIncludingScale(BigDecimal(10.01))
|
||||
expect(BigDecimal(456.01)).notToEqualIncludingScale(BigDecimal(456))
|
||||
expect(BigDecimal(-1.456)).notToEqualIncludingScale(BigDecimal(-1.45))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user