All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmTest.plot.builder.data.RingAssertion.kt Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2019. JetBrains s.r.o.
 * Use of this source code is governed by the MIT license that can be found in the LICENSE file.
 */

package jetbrains.datalore.plot.builder.data

import jetbrains.datalore.base.algorithms.calculateArea
import jetbrains.datalore.base.geometry.DoubleVector
import org.assertj.core.api.AbstractAssert
import org.assertj.core.api.Assertions

class RingAssertion internal constructor(ring: List) : AbstractAssert>(ring, RingAssertion::class.java) {

    val isClosed: RingAssertion
        get() {
            Assertions.assertThat(actual[0]).isEqualTo(actual[actual.size - 1])
            return this
        }

    fun hasSize(expected: Int): RingAssertion {
        Assertions.assertThat(actual).hasSize(expected)
        return this
    }

    fun hasArea(expected: Double): RingAssertion {
        return hasArea(expected, 0.001)
    }

    private fun hasArea(expected: Double, epsilon: Double): RingAssertion {
        Assertions.assertThat(calculateArea(actual)).isEqualTo(expected, Assertions.offset(epsilon))
        return this
    }

    companion object {

        fun assertThatRing(ring: List): RingAssertion {
            return RingAssertion(ring)
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy