Skip to content

Commit

Permalink
Rename tests in lesson 11/12 to avoid clashes in Kotoed grading
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-phoenix committed Nov 19, 2021
1 parent 1162e89 commit 2f4c3f6
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 74 deletions.
12 changes: 6 additions & 6 deletions test/lesson11/task1/ComplexTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ internal class ComplexTest {

@Test
@Tag("2")
fun plus() {
fun complexPlus() {
assertApproxEquals(Complex("4-2i"), Complex("1+2i") + Complex("3-4i"), 1e-10)
}

@Test
@Tag("2")
operator fun unaryMinus() {
fun complexUnaryMinus() {
assertApproxEquals(Complex(1.0, -2.0), -Complex(-1.0, 2.0), 1e-10)
}

@Test
@Tag("2")
fun minus() {
fun complexMinus() {
assertApproxEquals(Complex("2-6i"), Complex("3-4i") - Complex("1+2i"), 1e-10)
}

@Test
@Tag("4")
fun times() {
fun complexTimes() {
assertApproxEquals(Complex("11+2i"), Complex("1+2i") * Complex("3-4i"), 1e-10)
}

@Test
@Tag("4")
fun div() {
fun complexDiv() {
assertApproxEquals(Complex("1+2i"), Complex("11+2i") / Complex("3-4i"), 1e-10)
}

@Test
@Tag("2")
fun equals() {
fun complexEquals() {
assertApproxEquals(Complex(1.0, 2.0), Complex("1+2i"), 1e-12)
assertApproxEquals(Complex(1.0, 0.0), Complex(1.0), 1e-12)
}
Expand Down
16 changes: 8 additions & 8 deletions test/lesson11/task1/DimensionalValueTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class DimensionalValueTest {

@Test
@Tag("12")
fun base() {
fun dvBase() {
val first = DimensionalValue(1.0, "Kg")
assertEquals(1000.0, first.value)
assertEquals(Dimension.GRAM, first.dimension)
Expand All @@ -25,7 +25,7 @@ internal class DimensionalValueTest {

@Test
@Tag("6")
fun plus() {
fun dvPlus() {
assertApproxEquals(DimensionalValue("2 Km"), DimensionalValue("1 Km") + DimensionalValue("1000 m"), 1e-8)
assertThrows(IllegalArgumentException::class.java) {
DimensionalValue("1 g") + DimensionalValue("1 m")
Expand All @@ -34,13 +34,13 @@ internal class DimensionalValueTest {

@Test
@Tag("4")
operator fun unaryMinus() {
fun dvUnaryMinus() {
assertApproxEquals(DimensionalValue("-2 g"), -DimensionalValue("2 g"), 1e-12)
}

@Test
@Tag("6")
fun minus() {
fun dvMinus() {
assertApproxEquals(DimensionalValue("0 m"), DimensionalValue("1 Km") - DimensionalValue("1000 m"), 1e-10)
assertThrows(IllegalArgumentException::class.java) {
DimensionalValue("1 g") - DimensionalValue("1 m")
Expand All @@ -49,7 +49,7 @@ internal class DimensionalValueTest {

@Test
@Tag("4")
fun times() {
fun dvTimes() {
assertApproxEquals(DimensionalValue("2 Kg"), DimensionalValue("2 g") * 1000.0, 1e-8)
}

Expand All @@ -70,20 +70,20 @@ internal class DimensionalValueTest {

@Test
@Tag("4")
fun equals() {
fun dvEquals() {
assertEquals(DimensionalValue("1 Kg"), DimensionalValue("1 Kg"))
assertEquals(DimensionalValue("3 mm"), DimensionalValue("3 mm"))
}

@Test
@Tag("4")
fun hashCodeTest() {
fun dvHashCode() {
assertEquals(DimensionalValue("1 Kg").hashCode(), DimensionalValue("1 Kg").hashCode())
}

@Test
@Tag("4")
fun compareTo() {
fun dvCompareTo() {
assertTrue(DimensionalValue("1 Kg") < DimensionalValue("1500 g"))
assertTrue(DimensionalValue("1 m") > DimensionalValue("900 mm"))
}
Expand Down
22 changes: 11 additions & 11 deletions test/lesson11/task1/FixedPointNumberTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FixedPointNumberTest {

@Test
@Tag("6")
fun getPrecision() {
fun fpnGetPrecision() {
val n = FixedPointNumber("1.2345")
assertEquals(4, n.precision)
val m = FixedPointNumber(42)
Expand All @@ -18,62 +18,62 @@ class FixedPointNumberTest {

@Test
@Tag("6")
fun plus() {
fun fpnPlus() {
val x = FixedPointNumber("2.345")
val y = FixedPointNumber("19.7532")
assertEquals(FixedPointNumber("22.0982"), x + y)
}

@Test
@Tag("4")
operator fun unaryMinus() {
fun fpnUnaryMinus() {
val x = FixedPointNumber("2.345")
assertEquals(FixedPointNumber("-2.345"), -x)
}

@Test
@Tag("6")
fun minus() {
fun fpnMinus() {
val x = FixedPointNumber("2.345")
val y = FixedPointNumber("19.7532")
assertEquals(FixedPointNumber("17.4082"), y - x)
}

@Test
@Tag("10")
fun times() {
fun fpnTimes() {
val x = FixedPointNumber("2.345")
val y = FixedPointNumber("19.7532")
assertEquals(FixedPointNumber("46.3213"), x * y)
}

@Test
@Tag("10")
fun div() {
fun fpnDiv() {
val x = FixedPointNumber("2.345")
val y = FixedPointNumber("19.7532")
assertEquals(FixedPointNumber("8.424"), y / x)
}

@Test
@Tag("6")
fun testEquals() {
fun fpnEquals() {
val x = FixedPointNumber(19.7532, 4)
val y = FixedPointNumber("19.7532")
assertTrue(x == y)
}

@Test
@Tag("6")
fun testHashCode() {
fun fpnHashCode() {
val x = FixedPointNumber(19.7532, 4)
val y = FixedPointNumber("19.7532")
assertTrue(x.hashCode() == y.hashCode())
}

@Test
@Tag("6")
fun compareTo() {
fun fpnCompareTo() {
val x = FixedPointNumber("2.345")
val y = FixedPointNumber("19.7532")
assertTrue(y > x)
Expand All @@ -82,14 +82,14 @@ class FixedPointNumberTest {

@Test
@Tag("4")
fun testToString() {
fun fpnToString() {
val x = FixedPointNumber(19.7532, 4)
assertEquals("19.7532", x.toString())
}

@Test
@Tag("6")
fun toDouble() {
fun fpnToDouble() {
val x = FixedPointNumber("19.7532")
assertEquals(19.7532, x.toDouble(), 1e-5)
}
Expand Down
20 changes: 10 additions & 10 deletions test/lesson11/task1/PolynomTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class PolynomTest {

@Test
@Tag("4")
fun getValue() {
fun polynomGetValue() {
val p = Polynom(1.0, 3.0, 2.0)
assertEquals(42.0, p.getValue(5.0), 1e-10)
}

@Test
@Tag("4")
fun degree() {
fun polynomDegree() {
val p = Polynom(1.0, 1.0, 1.0)
assertEquals(2, p.degree())
val q = Polynom(0.0)
Expand All @@ -34,7 +34,7 @@ class PolynomTest {

@Test
@Tag("4")
fun plus() {
fun polynomPlus() {
val p1 = Polynom(1.0, -2.0, -1.0, 4.0)
val p2 = Polynom(1.0, 3.0, 2.0)
val r = Polynom(1.0, -1.0, 2.0, 6.0)
Expand All @@ -44,15 +44,15 @@ class PolynomTest {

@Test
@Tag("4")
operator fun unaryMinus() {
fun polynomUnaryMinus() {
val p = Polynom(1.0, -1.0, 2.0)
val r = Polynom(-1.0, 1.0, -2.0)
assertApproxEquals(r, -p, 1e-11)
}

@Test
@Tag("4")
fun minus() {
fun polynomMinus() {
val p1 = Polynom(1.0, -2.0, -1.0, 4.0)
val p2 = Polynom(1.0, 3.0, 2.0)
val r = Polynom(1.0, -3.0, -4.0, 2.0)
Expand All @@ -62,7 +62,7 @@ class PolynomTest {

@Test
@Tag("6")
fun times() {
fun polynomTimes() {
val p1 = Polynom(1.0, -2.0, -1.0, 4.0)
val p2 = Polynom(1.0, 3.0, 2.0)
val r = Polynom(1.0, 1.0, -5.0, -3.0, 10.0, 8.0)
Expand All @@ -72,7 +72,7 @@ class PolynomTest {

@Test
@Tag("8")
fun div() {
fun polynomDiv() {
val p1 = Polynom(1.0, -2.0, -1.0, 4.0)
val p2 = Polynom(1.0, 3.0, 2.0)
val r = Polynom(1.0, -5.0)
Expand All @@ -82,7 +82,7 @@ class PolynomTest {

@Test
@Tag("8")
fun rem() {
fun polynomRem() {
val p1 = Polynom(1.0, -2.0, -1.0, 4.0)
val p2 = Polynom(1.0, 3.0, 2.0)
val r = Polynom(1.0, -5.0)
Expand All @@ -93,14 +93,14 @@ class PolynomTest {

@Test
@Tag("4")
fun equals() {
fun polynomEquals() {
assertEquals(Polynom(1.0, 2.0, 3.0), Polynom(1.0, 2.0, 3.0))
assertEquals(Polynom(0.0, 2.0, 3.0), Polynom(2.0, 3.0))
}

@Test
@Tag("6")
fun hashCodeTest() {
fun polynomHashCode() {
assertEquals(Polynom(1.0, 2.0, 3.0).hashCode(), Polynom(1.0, 2.0, 3.0).hashCode())
}
}
20 changes: 10 additions & 10 deletions test/lesson11/task1/RationalTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test
class RationalTest {
@Test
@Tag("Example")
fun plus() {
fun rationalPlus() {
assertEquals(
Rational(1, 2),
Rational(1, 6) + Rational(1, 3)
Expand All @@ -17,7 +17,7 @@ class RationalTest {

@Test
@Tag("Example")
operator fun unaryMinus() {
fun rationalUnaryMinus() {
assertEquals(
Rational(1, 2),
-Rational(3, -6)
Expand All @@ -26,7 +26,7 @@ class RationalTest {

@Test
@Tag("Example")
fun minus() {
fun rationalMinus() {
assertEquals(
Rational(1, 3),
Rational(1, 2) - Rational(1, 6)
Expand All @@ -35,7 +35,7 @@ class RationalTest {

@Test
@Tag("Example")
fun times() {
fun rationalTimes() {
assertEquals(
Rational(3, 10),
Rational(3, 4) * Rational(2, 5)
Expand All @@ -44,7 +44,7 @@ class RationalTest {

@Test
@Tag("Example")
fun div() {
fun rationalDiv() {
assertEquals(
Rational(2, 5),
Rational(3, 10) / Rational(3, 4)
Expand All @@ -53,7 +53,7 @@ class RationalTest {

@Test
@Tag("Example")
fun toInt() {
fun rationalToInt() {
assertEquals(
1,
Rational(3, 2).toInt().toLong()
Expand All @@ -62,7 +62,7 @@ class RationalTest {

@Test
@Tag("Example")
fun toDouble() {
fun rationalToDouble() {
assertEquals(
0.5,
Rational(3, 6).toDouble(),
Expand All @@ -72,7 +72,7 @@ class RationalTest {

@Test
@Tag("Example")
fun equals() {
fun rationalEquals() {
assertEquals(
Rational(1, 2),
Rational(2, 4)
Expand All @@ -89,7 +89,7 @@ class RationalTest {

@Test
@Tag("Example")
fun divZero() {
fun rationalDivZero() {
assertThrows(ArithmeticException::class.java) {
Rational(1, 0)
}
Expand All @@ -106,7 +106,7 @@ class RationalTest {

@Test
@Tag("Example")
fun compare() {
fun rationalCompareTo() {
val a = Rational(1, 2)
val b = Rational(4, 7)
assertTrue(a.compareTo(a) == 0)
Expand Down
Loading

0 comments on commit 2f4c3f6

Please sign in to comment.