-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
snapshot/src/test/scala/com/evolutiongaming/kafka/journal/BufferNrSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.evolutiongaming.kafka.journal | ||
|
||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
class BufferNrSpec extends AnyFunSuite { | ||
|
||
type F[T] = Either[String, T] | ||
|
||
test("create BufferNr out of an Int") { | ||
BufferNr.of[F](17) match { | ||
case Left(message) => fail(message) | ||
case Right(bufferNr) => assert(bufferNr.value == 17) | ||
} | ||
} | ||
|
||
test("fail to create negative BufferNr") { | ||
BufferNr.of[F](-1) match { | ||
case Left(message) => assert(message == "invalid BufferNr of -1, it must be greater or equal to 0") | ||
case Right(bufferNr) => fail(s"exception was not thrown, but got $bufferNr instead") | ||
} | ||
} | ||
|
||
test("reuse BufferNr.min instance") { | ||
BufferNr.of[F](0) match { | ||
case Left(message) => fail(message) | ||
case Right(bufferNr) => assert(bufferNr == BufferNr.min) | ||
} | ||
} | ||
|
||
test("reuse BufferNr.max instance") { | ||
BufferNr.of[F](Int.MaxValue) match { | ||
case Left(message) => fail(message) | ||
case Right(bufferNr) => assert(bufferNr == BufferNr.max) | ||
} | ||
} | ||
|
||
test("use listOf") { | ||
assert(BufferNr.listOf(3).map(_.value) == List(0, 1, 2)) | ||
} | ||
|
||
} |