From b18012d77052d4831eac7c09ce1f70cf8b64dee4 Mon Sep 17 00:00:00 2001 From: Yilin Wei Date: Thu, 25 Jun 2020 22:19:51 +0100 Subject: [PATCH] Add explicit tests for helper methods --- .../main/scala/cats/kernel/Enumerable.scala | 2 ++ .../cats/tests/BoundedEnumerableSuite.scala | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/src/test/scala/cats/tests/BoundedEnumerableSuite.scala diff --git a/kernel/src/main/scala/cats/kernel/Enumerable.scala b/kernel/src/main/scala/cats/kernel/Enumerable.scala index 1c5e06354c..76f94d54b9 100644 --- a/kernel/src/main/scala/cats/kernel/Enumerable.scala +++ b/kernel/src/main/scala/cats/kernel/Enumerable.scala @@ -75,6 +75,8 @@ object BoundedEnumerable { cats.kernel.instances.long.catsKernelStdOrderForLong implicit def catsKernelBoundedEnumerableForChar: BoundedEnumerable[Char] = cats.kernel.instances.char.catsKernelStdOrderForChar + + @inline def apply[A](implicit e: BoundedEnumerable[A]): BoundedEnumerable[A] = e } trait LowerBoundedEnumerable[@sp A] extends PartialNextLowerBounded[A] with Next[A] { diff --git a/tests/src/test/scala/cats/tests/BoundedEnumerableSuite.scala b/tests/src/test/scala/cats/tests/BoundedEnumerableSuite.scala new file mode 100644 index 0000000000..e11c4eee5b --- /dev/null +++ b/tests/src/test/scala/cats/tests/BoundedEnumerableSuite.scala @@ -0,0 +1,23 @@ +package cats.tests + +import cats.kernel.BoundedEnumerable + +class BoundedEnumerableSuite extends CatsSuite { + + test("membersAscending") { + BoundedEnumerable[Boolean].membersAscending.toList should ===(List(false, true)) + } + + test("membersDescending") { + BoundedEnumerable[Boolean].membersDescending.toList should ===(List(true, false)) + } + + test("cycleNext") { + BoundedEnumerable[Boolean].cycleNext(false) should ===(true) + } + + test("cyclePrevious") { + BoundedEnumerable[Boolean].cyclePrevious(false) should ===(true) + } + +}