From 346f9f62a92bd8032208de922adb2b11fff4d14c Mon Sep 17 00:00:00 2001 From: Mike Curry Date: Thu, 19 Nov 2015 22:02:50 +0000 Subject: [PATCH 1/2] Add test for Show[OneAnd] Adds a test for the Show instance for OneAnd --- tests/src/test/scala/cats/tests/OneAndTests.scala | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/src/test/scala/cats/tests/OneAndTests.scala b/tests/src/test/scala/cats/tests/OneAndTests.scala index ee4170a43e..71d9a3b429 100644 --- a/tests/src/test/scala/cats/tests/OneAndTests.scala +++ b/tests/src/test/scala/cats/tests/OneAndTests.scala @@ -47,6 +47,14 @@ class OneAndTests extends CatsSuite { checkAll("NonEmptyList[Int]", ComonadTests[NonEmptyList].comonad[Int, Int, Int]) checkAll("Comonad[NonEmptyList[A]]", SerializableTests.serializable(Comonad[NonEmptyList])) + test("Show is not empty and is formatted as expected") { + forAll { (nel: NonEmptyList[Int]) => + nel.show.nonEmpty should === (true) + nel.show.startsWith("OneAnd") should === (true) + nel.show should === (implicitly[Show[NonEmptyList[Int]]].show(nel)) + } + } + test("Creating OneAnd + unwrap is identity") { forAll { (i: Int, tail: List[Int]) => val list = i :: tail From 0a2ac48a1e5ce0ead0da32660b16931dd65cda1e Mon Sep 17 00:00:00 2001 From: Mike Curry Date: Fri, 20 Nov 2015 20:43:30 +0000 Subject: [PATCH 2/2] Updated test to verify that the head of OneAnd is in the Show result, and an additional check that verifies an exact String result --- tests/src/test/scala/cats/tests/OneAndTests.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/src/test/scala/cats/tests/OneAndTests.scala b/tests/src/test/scala/cats/tests/OneAndTests.scala index 71d9a3b429..a37db01af1 100644 --- a/tests/src/test/scala/cats/tests/OneAndTests.scala +++ b/tests/src/test/scala/cats/tests/OneAndTests.scala @@ -50,11 +50,17 @@ class OneAndTests extends CatsSuite { test("Show is not empty and is formatted as expected") { forAll { (nel: NonEmptyList[Int]) => nel.show.nonEmpty should === (true) - nel.show.startsWith("OneAnd") should === (true) + nel.show.startsWith("OneAnd(") should === (true) nel.show should === (implicitly[Show[NonEmptyList[Int]]].show(nel)) + nel.show.contains(nel.head.show) should === (true) } } + test("Show is formatted correctly") { + val oneAnd = NonEmptyList("Test", Nil) + oneAnd.show should === ("OneAnd(Test, List())") + } + test("Creating OneAnd + unwrap is identity") { forAll { (i: Int, tail: List[Int]) => val list = i :: tail