Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added instances of BitSet to allInstances #1592

Merged
merged 3 commits into from
Apr 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/main/scala/cats/instances/all.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ trait AllInstances
with MapInstances
with BigIntInstances
with BigDecimalInstances
with BitSetInstances
with FutureInstances
with TryInstances
with TupleInstances
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/scala/cats/instances/bitSet.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cats.instances

import scala.collection.immutable.BitSet
import cats.Show

trait BitSetInstances extends cats.kernel.instances.BitSetInstances {
implicit def catsStdShowForBitSet: Show[BitSet] = Show.fromToString[BitSet]
}
1 change: 1 addition & 0 deletions core/src/main/scala/cats/instances/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package object instances {
object list extends ListInstances
object option extends OptionInstances
object set extends SetInstances
object bitSet extends BitSetInstances
object stream extends StreamInstances
object vector extends VectorInstances
object map extends MapInstances
Expand Down
21 changes: 21 additions & 0 deletions tests/src/test/scala/cats/tests/BitSetTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cats.tests

import org.scalacheck.Arbitrary
import org.scalacheck.Arbitrary.arbitrary

import scala.collection.immutable.BitSet

class BitSetTests extends CatsSuite {
implicit val arbitraryBitSet: Arbitrary[BitSet] =
Arbitrary(arbitrary[List[Short]].map(ns => BitSet(ns.map(_ & 0xffff): _*)))

test("show BitSet"){
BitSet(1, 1, 2, 3).show should === ("BitSet(1, 2, 3)")
BitSet.empty.show should === ("BitSet()")

forAll { fs: BitSet =>
fs.show should === (fs.toString)
}
}

}