Last active
October 2, 2017 17:46
-
-
Save kr3v/d8d590590e25a487f5020e9cb6360af5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.assertj.core.api.Assertions | |
import org.testng.annotations.DataProvider | |
import org.testng.annotations.Test | |
@Test(groups = arrayOf("utils")) | |
class DoubleUtilTests { | |
@Test(dataProvider = "comparisons") | |
fun tests(d1: Double, d2: Double, result: Int) { | |
Assertions.assertThat(d1 compareToWithEps d2).isEqualTo(result) | |
Assertions.assertThat(d2 compareToWithEps d1).isEqualTo(-result) | |
Assertions.assertThat(compareToWithEps(d1, d2)).isEqualTo(result) | |
Assertions.assertThat(compareToWithEps(d2, d1)).isEqualTo(-result) | |
} | |
@DataProvider | |
fun comparisons() = arrayOf( | |
arrayOf(1.0, 2.0, -1), | |
arrayOf(2.0, 1.0, 1), | |
arrayOf(1.0, 1.0, 0), | |
arrayOf(0.01, 0.02, -1), | |
arrayOf(0.02, 0.01, 1), | |
arrayOf(0.01, 0.019, 0), | |
arrayOf(0.019, 0.01, 0) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment