package solutions.bitbadger.documents import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test import kotlin.test.assertFalse import kotlin.test.assertTrue /** * Unit tests for the `Comparison` class */ @DisplayName("Comparison") class ComparisonTest { @Test @DisplayName("isNumeric is false for empty list of values") fun isNumericFalseForEmptyList() = assertFalse(Comparison(Op.IN, listOf()).isNumeric, "An IN with empty list should not be numeric") @Test @DisplayName("isNumeric is false for IN with strings") fun isNumericFalseForStringsAndIn() = assertFalse(Comparison(Op.IN, listOf("a", "b", "c")).isNumeric, "An IN with strings should not be numeric") @Test @DisplayName("isNumeric is true for IN with bytes") fun isNumericTrueForByteAndIn() = assertTrue(Comparison(Op.IN, listOf(4, 8)).isNumeric, "An IN with bytes should be numeric") @Test @DisplayName("isNumeric is true for IN with shorts") fun isNumericTrueForShortAndIn() = assertTrue(Comparison(Op.IN, listOf(18, 22)).isNumeric, "An IN with shorts should be numeric") @Test @DisplayName("isNumeric is true for IN with ints") fun isNumericTrueForIntAndIn() = assertTrue(Comparison(Op.IN, listOf(7, 8, 9)).isNumeric, "An IN with ints should be numeric") @Test @DisplayName("isNumeric is true for IN with longs") fun isNumericTrueForLongAndIn() = assertTrue(Comparison(Op.IN, listOf(3L)).isNumeric, "An IN with longs should be numeric") @Test @DisplayName("isNumeric is false for BETWEEN with strings") fun isNumericFalseForStringsAndBetween() = assertFalse(Comparison(Op.BETWEEN, Pair("eh", "zed")).isNumeric, "A BETWEEN with strings should not be numeric") @Test @DisplayName("isNumeric is true for BETWEEN with bytes") fun isNumericTrueForByteAndBetween() = assertTrue(Comparison(Op.BETWEEN, Pair(7, 11)).isNumeric, "A BETWEEN with bytes should be numeric") @Test @DisplayName("isNumeric is true for BETWEEN with shorts") fun isNumericTrueForShortAndBetween() = assertTrue(Comparison(Op.BETWEEN, Pair(0, 9)).isNumeric, "A BETWEEN with shorts should be numeric") @Test @DisplayName("isNumeric is true for BETWEEN with ints") fun isNumericTrueForIntAndBetween() = assertTrue(Comparison(Op.BETWEEN, Pair(15, 44)).isNumeric, "A BETWEEN with ints should be numeric") @Test @DisplayName("isNumeric is true for BETWEEN with longs") fun isNumericTrueForLongAndBetween() = assertTrue(Comparison(Op.BETWEEN, Pair(9L, 12L)).isNumeric, "A BETWEEN with longs should be numeric") @Test @DisplayName("isNumeric is false for string value") fun isNumericFalseForString() = assertFalse(Comparison(Op.EQUAL, "80").isNumeric, "A string should not be numeric") @Test @DisplayName("isNumeric is true for byte value") fun isNumericTrueForByte() = assertTrue(Comparison(Op.EQUAL, 47.toByte()).isNumeric, "A byte should be numeric") @Test @DisplayName("isNumeric is true for short value") fun isNumericTrueForShort() = assertTrue(Comparison(Op.EQUAL, 2.toShort()).isNumeric, "A short should be numeric") @Test @DisplayName("isNumeric is true for int value") fun isNumericTrueForInt() = assertTrue(Comparison(Op.EQUAL, 555).isNumeric, "An int should be numeric") @Test @DisplayName("isNumeric is true for long value") fun isNumericTrueForLong() = assertTrue(Comparison(Op.EQUAL, 82L).isNumeric, "A long should be numeric") }