How to use test method of io.kotest.matchers.floats.matchers class

Best Kotest code snippet using io.kotest.matchers.floats.matchers.test

EpochTest.kt

Source:EpochTest.kt Github

copy

Full Screen

1package io.blockfrost.sdk_kotlin.itests2import io.blockfrost.sdk_kotlin.api.CardanoEpochsApi3import io.blockfrost.sdk_kotlin.infrastructure.BlockfrostConfig4import io.kotest.core.spec.style.DescribeSpec5import io.kotest.matchers.collections.shouldNotBeEmpty6import io.kotest.matchers.floats.plusOrMinus7import io.kotest.matchers.ints.shouldBeLessThan8import io.kotest.matchers.nulls.shouldBeNull9import io.kotest.matchers.nulls.shouldNotBeNull10import io.kotest.matchers.shouldBe11import kotlin.properties.Delegates12import kotlin.time.Duration13import kotlin.time.ExperimentalTime14@OptIn(ExperimentalTime::class)15class EpochTest : DescribeSpec({16 var api: CardanoEpochsApi by Delegates.notNull()17 System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "INFO")18 describe("epochs"){19 beforeTest {20 api = CardanoEpochsApi(config = BlockfrostConfig.defaulMainNetConfig)21 }22 it("getLatest").config(timeout = Duration.Companion.seconds(10)){23 val r = api.getLatestEpoch()24 r.shouldNotBeNull()25 }26 it("epoch0").config(timeout = Duration.Companion.seconds(10)){27 val r = api.getEpoch(0)28 r.shouldNotBeNull()29 r.epoch.shouldBe(0)30 r.startTime.shouldBe(1506203091)31 r.endTime.shouldBe(1506635091)32 r.firstBlockTime.shouldBe(1506203091)33 r.lastBlockTime.shouldBe(1506635071)34 r.blockCount.shouldBe(21587)35 r.txCount.shouldBe(33)36 r.output.shouldBe("10378568796482912")37 r.fees.shouldBe("3458053")...

Full Screen

Full Screen

EnvironmentTest.kt

Source:EnvironmentTest.kt Github

copy

Full Screen

1package dev.cyberdeck.lisp2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.core.spec.style.ShouldSpec4import io.kotest.matchers.nulls.shouldNotBeNull5import io.kotest.matchers.shouldBe6import io.kotest.property.checkAll7import io.kotest.property.exhaustive.exhaustive8class EnvironmentTest : ShouldSpec({9 val stdEnv = standardEnv()10 context("nested environment") {11 should("find outer symbols") {12 val inner = env("a" to Num(1)).newInner()13 inner["a"].shouldNotBeNull()14 }15 should("allow shadowing of outer symbols") {16 val outer = env("a" to Num(1))17 val inner = outer.newInner(Symbol("a") to Num(2))18 inner["a"].shouldBe(Num(2))19 outer["a"].shouldBe(Num(1))20 }21 }22 context("std environment") {23 should("multiply longs") {24 checkAll<Long, Long> { l, r ->25 eval(listExp(Symbol("*"), Num(l), Num(r)), stdEnv).shouldBe(Num(l * r))26 }27 }28 should("divide longs") {29 checkAll<Long, Long> { l, r ->30 if (r != 0L) {31 eval(listExp(Symbol("/"), Num(l), Num(r)), stdEnv).shouldBe(Num(l / r))32 }33 }34 }35 should("add longs") {36 checkAll<Long, Long> { l, r ->37 eval(listExp(Symbol("+"), Num(l), Num(r)), stdEnv).shouldBe(Num(l + r))38 }39 }40 should("subtract longs") {41 checkAll<Long, Long> { l, r ->42 eval(listExp(Symbol("-"), Num(l), Num(r)), stdEnv).shouldBe(Num(l - r))43 }44 }45 should("multiply floats") {46 checkAll<Float, Float> { l, r ->47 eval(listExp(Symbol("*"), Num(l), Num(r)), stdEnv).shouldBe(Num(l * r))48 }49 }50 should("divide floats") {51 checkAll<Float, Float> { l, r ->52 if (r != 0.0f) {53 eval(listExp(Symbol("/"), Num(l), Num(r)), stdEnv).shouldBe(Num(l / r))54 }55 }56 }57 should("add floats") {58 checkAll<Float, Float> { l, r ->59 eval(listExp(Symbol("+"), Num(l), Num(r)), stdEnv).shouldBe(Num(l + r))60 }61 }62 should("subtract floats") {63 checkAll<Float, Float> { l, r ->64 eval(listExp(Symbol("-"), Num(l), Num(r)), stdEnv).shouldBe(Num(l - r))65 }66 }67 should("fail with mixed numeric types") {68 val operators = listOf("-", "*", "/", "+").map { Symbol(it) }.exhaustive()69 checkAll<Float, Int> { l, r ->70 checkAll(operators) { op ->71 shouldThrow<RuntimeErr> {72 eval(listExp(op, Num(l), Num(r)), stdEnv)73 }74 }75 }76 checkAll<Int, Float> { l, r ->77 checkAll(operators) { op ->78 shouldThrow<RuntimeErr> {79 eval(listExp(op, Num(l), Num(r)), stdEnv)80 }81 }82 }83 }84 }85 context("require") {86 should("define into current scope") {87 val reqTest = listExp(Symbol("require"), LString("test"))88 val env = Environment(loader = {89 listExp(Symbol("define"), Symbol("a"), Num(1))90 })91 eval(reqTest, env = env)92 env["a"].shouldBe(Num(1))93 }94 should("propagate syntax errors") {95 shouldThrow<RuntimeErr> {96 val reqTest = listExp(Symbol("require"), LString("test"))97 eval(reqTest, env = Environment(loader = {throw SyntaxErr("oops")}))98 }99 }100 }101})...

Full Screen

Full Screen

FloatNaNTest.kt

Source:FloatNaNTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.floats2import com.sksamuel.kotest.matchers.doubles.numericFloats3import io.kotest.assertions.throwables.shouldThrow4import io.kotest.core.spec.style.FunSpec5import io.kotest.matchers.floats.beNaN6import io.kotest.matchers.floats.shouldBeNaN7import io.kotest.matchers.floats.shouldNotBeNaN8import io.kotest.matchers.should9import io.kotest.matchers.shouldBe10import io.kotest.matchers.shouldNot11import io.kotest.property.checkAll12class FloatNaNTest : FunSpec() {13 init {14 context("NaN matcher") {15 test("Every numeric float should not be NaN") {16 checkAll(100, numericFloats) {17 it.shouldNotMatchNaN()18 }19 }20 test("The non-numeric floats") {21 Float.NaN.shouldMatchNaN()22 Float.POSITIVE_INFINITY.shouldNotMatchNaN()23 Float.NEGATIVE_INFINITY.shouldNotMatchNaN()24 }25 }26 }27 private fun Float.shouldMatchNaN() {28 this should beNaN()29 this.shouldBeNaN()30 this.shouldThrowExceptionOnNotBeNaN()31 }32 private fun Float.shouldNotMatchNaN() {33 this shouldNot beNaN()34 this.shouldNotBeNaN()...

Full Screen

Full Screen

BMITests.kt

Source:BMITests.kt Github

copy

Full Screen

1package com.example.bmimaster2import io.kotest.core.spec.style.FunSpec3import io.kotest.data.forAll4import io.kotest.matchers.doubles.plusOrMinus5import io.kotest.matchers.floats.plusOrMinus6import io.kotest.matchers.shouldBe7import io.kotest.property.Arb8import io.kotest.property.arbitrary.*9import io.kotest.property.checkAll10import org.junit.jupiter.api.Test11class BMITests : FunSpec({12 test("metric single value") {13 val height = 180f14 val weight = 80f15 val (bmi, _) = BMI.getBMI(height, weight, MeasureSystem.Metric)16 bmi shouldBe 24.7f.plusOrMinus(0.1f)17 }18 test("imperial single value") {19 val height = 72f20 val weight = 170f21 val (bmi, _) = BMI.getBMI(height, weight, MeasureSystem.Imperial)22 bmi shouldBe 23.1f.plusOrMinus(0.1f)23 }24 //For some reason numericFloats won't work :<25 test("metric many values"){26 checkAll(Arb.numericDoubles(100.0, 200.0), Arb.numericDoubles(1.0, 200.0)){ height, weight ->27 BMI.getBMI(height.toFloat(), weight.toFloat(), MeasureSystem.Metric).first.toDouble() shouldBe (weight/(height/100.0)/(height/100.0)).plusOrMinus(28 0.529 )30 }31 }32 //Same as above33 test("imperial many values"){34 checkAll(Arb.numericDoubles(50.0, 100.0), Arb.numericDoubles(100.0, 200.0)){ height, weight ->35 BMI.getBMI(height.toFloat(), weight.toFloat(), MeasureSystem.Imperial).first.toDouble() shouldBe (weight/(height)/(height)*703).plusOrMinus(36 0.537 )38 }39 }40})...

Full Screen

Full Screen

IntegrationTest.kt

Source:IntegrationTest.kt Github

copy

Full Screen

1package dev.cyberdeck.lisp2import io.kotest.core.spec.style.StringSpec3import io.kotest.matchers.floats.shouldBeBetween4import io.kotest.matchers.result.shouldBeSuccess5import io.kotest.matchers.shouldBe6import io.kotest.matchers.types.shouldBeInstanceOf7fun run(prog: String) = Result.runCatching {8 val tokens = tokenize(prog)9 val ast = readFromTokens(tokens)10 val env = standardEnv()11 eval(ast, env)12}13class IntegrationTest : StringSpec({14 "eval should work on complex expressions" {15 run("(begin (define r 10.0) (* pi (* r r)))").shouldBeSuccess {16 it.shouldBeInstanceOf<Num>().num.shouldBeInstanceOf<Float>().shouldBeBetween(314.1592f, 314.1593f, 0.0f)17 }18 }19 "head returns the first element" {20 run("(begin (head (quote (hello))))").shouldBeSuccess {...

Full Screen

Full Screen

PositDecodeTest.kt

Source:PositDecodeTest.kt Github

copy

Full Screen

1package lib.posit2import io.kotest.core.spec.style.StringSpec3import io.kotest.matchers.doubles.shouldBeLessThan4import io.kotest.matchers.floats.shouldBeLessThan5import io.kotest.matchers.shouldBe6import kotlin.math.abs7/**8 * Тесты для декодирования числа Posit.9 */10class PositDecodeTest : StringSpec() {11 init {12 val array = doubleArrayOf(0.0, 1.0, 113.0, 1923.0, 0.003456, 12312.9899, -1.0, -1321.11)13 for (i in array.indices){14 "Decode to double"{15 abs(Posit(array[i]).toDouble() - array[i]) shouldBeLessThan 0.0116 }17 }18 for (i in array.indices){19 "Decode to float"{...

Full Screen

Full Screen

WeatherServiceImplTest.kt

Source:WeatherServiceImplTest.kt Github

copy

Full Screen

1package com.ets.androiddev.data.services2import com.ets.androiddev.di.AppModule3import com.ets.androiddev.domain.entities.Place4import io.kotest.matchers.floats.shouldBeGreaterThanOrEqual5import io.kotest.matchers.ints.shouldBeGreaterThan6import io.kotest.matchers.ints.shouldBeGreaterThanOrEqual7import io.kotest.matchers.should8import io.kotest.matchers.shouldBe9import org.junit.Test10class WeatherServiceImplTest {11 private val weatherService = AppModule.provideWeatherService()12 @Test13 fun `Service returns sensible values`() {14 with(weatherService.getCurrent(Place.NewYork)) {15 humidity shouldBeGreaterThan 016 pressure shouldBeGreaterThan 017 precipitation shouldBeGreaterThanOrEqual 0f18 windSpeed shouldBeGreaterThanOrEqual 019 temperature.asCelsius() should { it > -80 && it < 80 }20 }21 }22 @Test...

Full Screen

Full Screen

ext_scalarConstants.kt

Source:ext_scalarConstants.kt Github

copy

Full Screen

1package glm_.ext2import glm_.glm3import io.kotest.core.spec.style.StringSpec4import io.kotest.matchers.doubles.shouldBeGreaterThan5import io.kotest.matchers.doubles.shouldBeLessThan6import io.kotest.matchers.floats.shouldBeGreaterThan7import io.kotest.matchers.floats.shouldBeLessThan8class ext_scalarConstants : StringSpec() {9 init {10 "epsilon" {11 run {12 val test = glm.εf13 test shouldBeGreaterThan 0f14 }15 run {16 val test = glm.ε17 test shouldBeGreaterThan 0.018 }19 }20 "pi" {21 run {22 val test = glm.πf23 test shouldBeGreaterThan 3.14f24 test shouldBeLessThan 3.15f25 }26 run {27 val test = glm.π28 test shouldBeGreaterThan 3.1429 test shouldBeLessThan 3.1530 }31 }32 }33}...

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1assertThat(1.1f).isGreaterThan(1.0f)2assertThat(1.1f).isLessThan(2.0f)3assertThat(1.1f).isBetween(1.0f, 2.0f)4assertThat(1.1f).isBetween(1.0f, 2.0f, true, true)5assertThat(1.1f).isBetween(1.0f, 2.0f, false, true)6assertThat(1.1f).isBetween(1.0f, 2.0f, true, false)7assertThat(1.1f).isBetween(1.0f, 2.0f, false, false)8assertThat(1.1f).isGreaterThan(1.0f)9assertThat(1.1f).isLessThan(2.0f)10assertThat(1.1f).isBetween(1.0f, 2.0f)11assertThat(1.1f).isBetween(1.0f, 2.0f, true, true)12assertThat(1.1f).isBetween(1.0f, 2.0f, false, true)13assertThat(1.1f).isBetween(1.0f, 2.0f, true, false)14assertThat(1.1f).isBetween(1.0f, 2.0f, false, false)15assertThat(1.1f).isGreaterThan(1.0f)16assertThat(1.1f).isLessThan(2.0f)17assertThat(1.1f).isBetween(1.0f, 2.0f)18assertThat(1.1f).isBetween(1.0f, 2.0f, true, true)19assertThat(1.1f).isBetween(1.0f, 2.0f, false, true)20assertThat(1.1f).isBetween(1.0f, 2.0f, true, false)21assertThat(1.1f).is

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1 fun testFloat() {2 1.0f.shouldBeLessThan(2.0f)3 }4 fun testInt() {5 1.shouldBeLessThan(2)6 }7 fun testLong() {8 1L.shouldBeLessThan(2L)9 }10 fun testShort() {11 1.toShort().shouldBeLessThan(2.toShort())12 }13 fun testBoolean() {14 true.shouldBeTrue()15 }16 fun testDouble() {17 1.0.shouldBeLessThan(2.0)18 }19 fun testDouble2() {20 1.0.shouldBeLessThan(2.0)21 }22 fun testDouble3() {23 1.0.shouldBeLessThan(2.0)24 }25 fun testDouble4() {26 1.0.shouldBeLessThan(2.0)27 }28 fun testDouble5() {29 1.0.shouldBeLessThan(2.0)30 }31 fun testDouble6() {32 1.0.shouldBeLessThan(2.0)33 }

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1a.shouldBe(b)2a.shouldBe(b)3a.shouldBe(b)4a.shouldBe(b)5val a = 1.toShort()6val b = 1.toShort()7a.shouldBe(b)8val a = 1.toByte()9val b = 1.toByte()10a.shouldBe(b)11a.shouldBe(b)12a.shouldBe(b)13val a = 1.toBigDecimal()14val b = 1.toBigDecimal()15a.shouldBe(b)16val a = 1.toBigInteger()17val b = 1.toBigInteger()18a.shouldBe(b)19val a = RuntimeException("error")20val b = RuntimeException("error")21a.shouldBe(b)22val a = listOf(1,2,3)23val b = listOf(1,2,3)24a.shouldBe(b)25val a = mapOf("one" to 1, "two" to 2)26val b = mapOf("one" to 1,

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1result should be(10.0f)2result should be(10)3result should be(10L)4val result = 10.toShort()5result should be(10.toShort())6result should be("test")7result should be(true)8val result = listOf("test")9result should be(listOf("test"))10result should be(10.0)11val result = mapOf("test" to "test")12result should be(mapOf("test" to "test"))13result should be(null)14val result = sequenceOf("test")15result should be(sequenceOf("test"))16val result = Throwable("test")17result should be(Throwable("test"))18result should be("test")19val result = listOf("test")20result should be(listOf("test"))21val result = mapOf("test" to "test")22result should be(mapOf("test" to "test"))

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful