Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kotlin.test.assertEquals
- import kotlin.test.assertFalse
- import kotlin.test.assertTrue
- import org.junit.Test
- class TestFindAverageWithoutDuplicates{
- @Test
- fun noDuplicates() {
- val input = arrayOf(1, 2, 3, 4, 5)
- val expected = Pair(false, 3.0)
- val actual = findAverageWithoutDuplicates(input)
- assertEquals(expected, actual)
- }
- @Test
- fun withDuplicates() {
- val input = arrayOf(1, 2, 3, 4, 5, 5)
- val expected = Pair(true, 3.0)
- val actual = findAverageWithoutDuplicates(input)
- assertEquals(expected, actual)
- }
- @Test
- fun allDuplicates() {
- val input = arrayOf(1, 1, 1, 1, 1)
- val expected = Pair(true, 1.0)
- val actual = findAverageWithoutDuplicates(input)
- assertEquals(expected, actual)
- }
- @Test
- fun emptyInput() {
- val input = emptyArray<Int>()
- val expected = Pair(false, Double.NaN)
- val actual = findAverageWithoutDuplicates(input)
- assertEquals(expected, actual)
- }
- @Test
- fun oneNumber() {
- val input = arrayOf(1)
- val expected = Pair(false, 1.0)
- val actual = findAverageWithoutDuplicates(input)
- assertEquals(expected, actual)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement