Advertisement
ProgNeo

Untitled

Mar 3rd, 2023
1,048
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.27 KB | None | 0 0
  1. import kotlin.test.assertEquals
  2. import kotlin.test.assertFalse
  3. import kotlin.test.assertTrue
  4. import org.junit.Test
  5.  
  6. class TestFindAverageWithoutDuplicates{
  7.     @Test
  8.     fun noDuplicates() {
  9.         val input = arrayOf(1, 2, 3, 4, 5)
  10.         val expected = Pair(false, 3.0)
  11.         val actual = findAverageWithoutDuplicates(input)
  12.         assertEquals(expected, actual)
  13.     }
  14.  
  15.     @Test
  16.     fun withDuplicates() {
  17.         val input = arrayOf(1, 2, 3, 4, 5, 5)
  18.         val expected = Pair(true, 3.0)
  19.         val actual = findAverageWithoutDuplicates(input)
  20.         assertEquals(expected, actual)
  21.     }
  22.  
  23.     @Test
  24.     fun allDuplicates() {
  25.         val input = arrayOf(1, 1, 1, 1, 1)
  26.         val expected = Pair(true, 1.0)
  27.         val actual = findAverageWithoutDuplicates(input)
  28.         assertEquals(expected, actual)
  29.     }
  30.  
  31.     @Test
  32.     fun emptyInput() {
  33.         val input = emptyArray<Int>()
  34.         val expected = Pair(false, Double.NaN)
  35.         val actual = findAverageWithoutDuplicates(input)
  36.         assertEquals(expected, actual)
  37.     }
  38.  
  39.     @Test
  40.     fun oneNumber() {
  41.         val input = arrayOf(1)
  42.         val expected = Pair(false, 1.0)
  43.         val actual = findAverageWithoutDuplicates(input)
  44.         assertEquals(expected, actual)
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement