Skip to content

Commit

Permalink
feat(tests): unit test for cardinal detection
Browse files Browse the repository at this point in the history
  • Loading branch information
LizAinslie committed Sep 24, 2022
1 parent 5314d57 commit 831b192
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
3 changes: 1 addition & 2 deletions app/src/main/java/dev/synapsetech/compass/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch


private enum class Cardinal(val letter: String, val degree: Int) {
enum class Cardinal(val letter: String, val degree: Int) {
NORTH("N", 0),
EAST("E", 90),
SOUTH("S", 180),
Expand Down
27 changes: 27 additions & 0 deletions app/src/test/java/dev/synapsetech/compass/CardinalEnumTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package dev.synapsetech.compass

import org.junit.Test

import org.junit.Assert.*

class CardinalEnumTest {
@Test
fun detection_isCorrect() {
assertEquals(Cardinal.NORTH, Cardinal.fromDegree(0))
assertEquals(Cardinal.NORTH, Cardinal.fromDegree(360))
assertEquals(Cardinal.NORTH, Cardinal.fromDegree(10))
assertEquals(Cardinal.NORTH, Cardinal.fromDegree(350))

assertEquals(Cardinal.EAST, Cardinal.fromDegree(90))
assertEquals(Cardinal.EAST, Cardinal.fromDegree(83))
assertEquals(Cardinal.EAST, Cardinal.fromDegree(99))

assertEquals(Cardinal.SOUTH, Cardinal.fromDegree(180))
assertEquals(Cardinal.SOUTH, Cardinal.fromDegree(172))
assertEquals(Cardinal.SOUTH, Cardinal.fromDegree(194))

assertEquals(Cardinal.WEST, Cardinal.fromDegree(270))
assertEquals(Cardinal.WEST, Cardinal.fromDegree(267))
assertEquals(Cardinal.WEST, Cardinal.fromDegree(286))
}
}
17 changes: 0 additions & 17 deletions app/src/test/java/dev/synapsetech/compass/ExampleUnitTest.kt

This file was deleted.

0 comments on commit 831b192

Please sign in to comment.