Skip to content

Commit

Permalink
added instances of BitSet to allInstances (#1592)
Browse files Browse the repository at this point in the history
* added instances of BitSet to allInstances

* unnecessary show implementation

* removed unused imports
  • Loading branch information
kailuowang authored Apr 8, 2017
1 parent 62af31f commit 40194da
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
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)
}
}

}

0 comments on commit 40194da

Please sign in to comment.