How to use BigDecimal.shouldBeNegative method of io.kotest.matchers.bigdecimal.matchers class

Best Kotest code snippet using io.kotest.matchers.bigdecimal.matchers.BigDecimal.shouldBeNegative

BigDecimalMatchersTest.kt

Source:BigDecimalMatchersTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.bigdecimal2import io.kotest.matchers.bigdecimal.shouldBeGreaterThan3import io.kotest.matchers.bigdecimal.shouldBeGreaterThanOrEquals4import io.kotest.matchers.bigdecimal.shouldBeInRange5import io.kotest.matchers.bigdecimal.shouldBeLessThan6import io.kotest.matchers.bigdecimal.shouldBeLessThanOrEquals7import io.kotest.matchers.bigdecimal.shouldBeNegative8import io.kotest.matchers.bigdecimal.shouldBePositive9import io.kotest.matchers.bigdecimal.shouldBeZero10import io.kotest.matchers.bigdecimal.shouldHavePrecision11import io.kotest.matchers.bigdecimal.shouldHaveScale12import io.kotest.matchers.bigdecimal.shouldNotBeGreaterThan13import io.kotest.matchers.bigdecimal.shouldNotBeGreaterThanOrEquals14import io.kotest.matchers.bigdecimal.shouldNotBeInRange15import io.kotest.matchers.bigdecimal.shouldNotBeLessThan16import io.kotest.matchers.bigdecimal.shouldNotBeLessThanOrEquals17import io.kotest.matchers.bigdecimal.shouldNotHaveScale18import io.kotest.core.spec.style.StringSpec19import java.math.BigDecimal20class BigDecimalMatchersTest : StringSpec() {21 init {22 "shouldBeZero" {23 BigDecimal.ZERO.shouldBeZero()24 BigDecimal(0).shouldBeZero()25 0.toBigDecimal().shouldBeZero()26 }27 "shouldHavePrecision" {28 BigDecimal(10).setScale(3) shouldHavePrecision 529 BigDecimal(10.1) shouldHavePrecision 5130 10.1.toBigDecimal() shouldHavePrecision 331 BigDecimal.ZERO shouldHavePrecision 132 }33 "shouldHaveScale" {34 BigDecimal(10).setScale(3) shouldHaveScale 335 BigDecimal(10.1) shouldHaveScale 4936 10.444.toBigDecimal() shouldHaveScale 337 0.toBigDecimal() shouldHaveScale 038 BigDecimal.ZERO shouldHaveScale 039 BigDecimal(10).setScale(3) shouldNotHaveScale 140 BigDecimal(10.1) shouldNotHaveScale 541 10.444.toBigDecimal() shouldNotHaveScale 242 0.toBigDecimal() shouldNotHaveScale 143 BigDecimal.ZERO shouldNotHaveScale 244 }45 "shouldBePositive" {46 BigDecimal(10).shouldBePositive()47 BigDecimal.ZERO.shouldBePositive()48 BigDecimal(0.1).shouldBePositive()49 0.1.toBigDecimal().shouldBePositive()50 }51 "shouldBeNegative" {52 BigDecimal(-1).shouldBeNegative()53 (-1).toBigDecimal().shouldBeNegative()54 BigDecimal(-0.1).shouldBeNegative()55 BigDecimal(1).minus(BigDecimal(2)).shouldBeNegative()56 }57 "shouldBeGreaterThan" {58 BigDecimal.ONE shouldBeGreaterThan BigDecimal.ZERO59 BigDecimal.TEN shouldBeGreaterThan BigDecimal.ONE60 BigDecimal.ONE shouldNotBeGreaterThan BigDecimal.ONE61 BigDecimal.ONE shouldNotBeGreaterThan BigDecimal.TEN62 BigDecimal.TEN shouldNotBeGreaterThan BigDecimal.TEN63 }64 "shouldBeGreaterThanOrEquals" {65 BigDecimal.ONE shouldBeGreaterThanOrEquals BigDecimal.ZERO66 BigDecimal.ONE shouldBeGreaterThanOrEquals BigDecimal.ONE67 BigDecimal.TEN shouldBeGreaterThanOrEquals BigDecimal.ONE68 BigDecimal.TEN shouldBeGreaterThanOrEquals BigDecimal.TEN69 BigDecimal.ONE shouldNotBeGreaterThanOrEquals BigDecimal.TEN70 BigDecimal.ZERO shouldNotBeGreaterThanOrEquals BigDecimal.ONE71 }72 "shouldBeLessThan" {73 BigDecimal.ZERO shouldBeLessThan BigDecimal.ONE74 BigDecimal.ONE shouldBeLessThan BigDecimal.TEN75 BigDecimal.ONE shouldNotBeLessThan BigDecimal.ONE76 BigDecimal.TEN shouldNotBeLessThan BigDecimal.ONE77 BigDecimal.TEN shouldNotBeLessThan BigDecimal.TEN78 }79 "shouldBeLessThanOrEquals" {80 BigDecimal.ZERO shouldBeLessThanOrEquals BigDecimal.ONE81 BigDecimal.ONE shouldBeLessThanOrEquals BigDecimal.ONE82 BigDecimal.ONE shouldBeLessThanOrEquals BigDecimal.TEN83 BigDecimal.TEN shouldBeLessThanOrEquals BigDecimal.TEN84 BigDecimal.TEN shouldNotBeLessThanOrEquals BigDecimal.ONE85 BigDecimal.ONE shouldNotBeLessThanOrEquals BigDecimal.ZERO86 }87 "shouldBeInRange" {88 BigDecimal.ZERO shouldBeInRange BigDecimal(-1) .. BigDecimal(1)89 BigDecimal.ONE shouldBeInRange BigDecimal(-1) .. BigDecimal(1)90 (-BigDecimal.ONE) shouldBeInRange BigDecimal(-1) .. BigDecimal(1)91 BigDecimal.TEN shouldNotBeInRange BigDecimal(-1) .. BigDecimal(1)92 }93 }94}...

Full Screen

Full Screen

matchers.kt

Source:matchers.kt Github

copy

Full Screen

1package io.kotest.matchers.bigdecimal2import io.kotest.matchers.comparables.gt3import io.kotest.matchers.comparables.gte4import io.kotest.matchers.comparables.lt5import io.kotest.matchers.comparables.lte6import io.kotest.matchers.Matcher7import io.kotest.matchers.MatcherResult8import io.kotest.matchers.should9import io.kotest.matchers.shouldBe10import io.kotest.matchers.shouldNot11import io.kotest.matchers.shouldNotBe12import java.math.BigDecimal13fun BigDecimal.shouldBeZero() = this shouldBe BigDecimal.ZERO14fun BigDecimal.shouldBePositive() = this shouldBe gte(BigDecimal.ZERO)15fun BigDecimal.shouldBeNegative() = this shouldBe lt(BigDecimal.ZERO)16infix fun BigDecimal.shouldHavePrecision(precision: Int) = this.precision() shouldBe precision17infix fun BigDecimal.shouldHaveScale(scale: Int) = this.scale() shouldBe scale18infix fun BigDecimal.shouldNotHaveScale(scale: Int) = this.scale() shouldNotBe scale19infix fun BigDecimal.shouldBeLessThan(other: BigDecimal) = this shouldBe lt(other)20infix fun BigDecimal.shouldBeLessThanOrEquals(other: BigDecimal) = this shouldBe lte(other)21infix fun BigDecimal.shouldNotBeLessThan(other: BigDecimal) = this shouldNotBe lt(other)22infix fun BigDecimal.shouldNotBeLessThanOrEquals(other: BigDecimal) = this shouldNotBe lte(other)23infix fun BigDecimal.shouldBeGreaterThan(other: BigDecimal) = this shouldBe gt(other)24infix fun BigDecimal.shouldBeGreaterThanOrEquals(other: BigDecimal) = this shouldBe gte(other)25infix fun BigDecimal.shouldNotBeGreaterThan(other: BigDecimal) = this shouldNotBe gt(other)26infix fun BigDecimal.shouldNotBeGreaterThanOrEquals(other: BigDecimal) = this shouldNotBe gte(other)27infix fun BigDecimal.shouldBeInRange(range: ClosedRange<BigDecimal>) = this should beInClosedRange(range)28infix fun BigDecimal.shouldNotBeInRange(range: ClosedRange<BigDecimal>) = this shouldNot beInClosedRange(range)29fun beInClosedRange(range: ClosedRange<BigDecimal>) = object : Matcher<BigDecimal> {30 override fun test(value: BigDecimal) = MatcherResult(31 range.contains(value),32 { "Value $value should be in range from ${range.start} to ${range.endInclusive} (Inclusive)" },33 {34 "Value $value should not be in range from ${range.start} to ${range.endInclusive} (Inclusive)"35 })36}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful