Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aartiPl committed Aug 21, 2023
1 parent 5878249 commit 98154ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ import java.util.concurrent.atomic.AtomicInteger
class IntGenerator(sequenceStart: Int = Int.MIN_VALUE) : Generator<Int> {
private val counter = AtomicInteger(sequenceStart)

override fun next(): Int =
counter.getAndIncrement()

override fun next(): Int = counter.getAndIncrement()
}
31 changes: 31 additions & 0 deletions src/test/kotlin/net/igsoft/typeutils/generator/IntGeneratorTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.igsoft.typeutils.generator

import assertk.assertThat
import assertk.assertions.isEqualTo
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

class IntGeneratorTest {
private lateinit var intGenerator: IntGenerator

@BeforeEach
fun setUp() {
intGenerator = IntGenerator()
}

@Test
fun `Assert that initial value in IntGenerator can be set`() {
assertThat(IntGenerator(15).next()).isEqualTo(15)
}

@Test
fun `Assert that next is generating consecutive numbers`() {
var last = intGenerator.next()

(0..100).forEach {
val current = intGenerator.next()
assertThat(current - last).isEqualTo(1)
last = current
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DefaultTypedMarkerTest {

@Test
fun `Assert that TypedMarker can be created manually`() {
assertThat(DefaultTypedMarker.create(String::class.java, "s1")).apply {
assertThat(DefaultTypedMarker(String::class.java, "s1")).apply {
prop(DefaultTypedMarker<String>::clazz).isEqualTo(String::class.java)
prop(DefaultTypedMarker<String>::id).isEqualTo("s1")
}
Expand Down

0 comments on commit 98154ca

Please sign in to comment.