Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
added ClockWallTest.kt #2
Browse files Browse the repository at this point in the history
  • Loading branch information
V3lop5 committed Mar 7, 2021
1 parent fa100e3 commit 7fe40a5
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/model/ClockWallTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.adclock.model

import kotlin.test.Test
import kotlin.test.assertEquals

class ClockWallTest {

@Test
fun emptyClockWall() {
val wall = ClockWall(0, 0)
assertEquals(0, wall.clocks.size)
}


@Test
fun singleClockClockWall() {
val wall = ClockWall(1, 1)
assertEquals(1, wall.clocks.size)
assertEquals(1, wall.clocks.first().id)
assertEquals(0, wall.clocks.first().posX)
assertEquals(0, wall.clocks.first().posY)
}


@Test
fun quadClockClockWall() {
val wall = ClockWall(2, 2)
assertEquals(4, wall.clocks.size)

// first clock
assertEquals(1, wall.clocks.first().id)
assertEquals(0, wall.clocks.first().posX)
assertEquals(0, wall.clocks.first().posY)
// 2nd clock
assertEquals(2, wall.clocks.component2().id)
assertEquals(0, wall.clocks.component2().posX)
assertEquals(1, wall.clocks.component2().posY)
// 3rd clock
assertEquals(3, wall.clocks.component3().id)
assertEquals(1, wall.clocks.component3().posX)
assertEquals(0, wall.clocks.component3().posY)
// 4th clock
assertEquals(4, wall.clocks.component4().id)
assertEquals(1, wall.clocks.component4().posX)
assertEquals(1, wall.clocks.component4().posY)
}


@Test
fun clockWallGetClock() {
val wall = ClockWall(5, 3)
wall.clocks.forEach { comp ->
assertEquals(comp.id, wall.getClock(comp.posX, comp.posY).id, "GetClock for x${comp.posX} y${comp.posY} ")
}
}
}

0 comments on commit 7fe40a5

Please sign in to comment.