Permalink
Browse files

Some tests for lenses.

  • Loading branch information...
folone committed Dec 27, 2012
1 parent 2a643c6 commit 1b76721497ae397a22e2d94d727c6f58696e7406
View
@@ -57,7 +57,6 @@ object Build extends Build {
"org.scalaz" %% "scalaz-core" % "7.0.0-M7",
"org.scalaz" %% "scalaz-effect" % "7.0.0-M7",
"org.specs2" %% "specs2" % "1.12.3" % "test",
- "junit" % "junit" % "4.7" % "test",
"org.scalacheck" %% "scalacheck" % "1.10.0" % "test" cross CrossVersion.full,
"org.scalaz" %% "scalaz-scalacheck-binding" % "7.0.0-M7" % "test"
),
@@ -0,0 +1,47 @@
+package info.folone.scala.poi
+
+import org.specs2.mutable._
+
+class PoiLensesSpec extends Specification {
+ "Lenses on poi classes" should {
+ "cellLens getter" >> {
+ cellLens.get(Cell(1, "data")) must beEqualTo("data")
+ }
+ "cellLens setter" >> {
+ cellLens.set(Cell(1, "data"), "newData") must beEqualTo(Cell(1, "newData"))
+ }
+ "rowLens contains" >> {
+ rowLens.contains(Cell(2, "data1")).get(Row(1)(Set(Cell(1,"data"), Cell(2, "data1")))) must beTrue
+ }
+ "rowLens does not contain" >> {
+ rowLens.contains(Cell(2, "data1")).get(Row(1)(Set(Cell(1,"data"), Cell(2, "data")))) must beFalse
+ }
+ "rowLens +=" >> {
+ (rowLens += Cell(2, "data1")).run(Row(1)(Set(Cell(1, "data"), Cell(3, "data3")))) mustEqual
+ (Row(1)
+ (Set(Cell(1,"data"), Cell(3, "data3"), Cell(2, "data1"))),
+ Set(Cell(1, "data"), Cell(3, "data3"), Cell(2, "data1")))
+ }
+ "rowLens &=" >> {
+ (rowLens &= Set(Cell(2, "data1"))).run(Row(1)(Set(Cell(1, "data"), Cell(2, "data1")))) mustEqual
+ (Row(1)(Set(Cell(2, "data1"))),Set(Cell(2, "data1")))
+ }
+ "rowLens &~=" >> {
+ (rowLens &~= Set(Cell(2, "data1"))).run(Row(1)(Set(Cell(1, "data"), Cell(2, "data1")))) mustEqual
+ (Row(1)(Set(Cell(1, "data"))),Set(Cell(1, "data")))
+ }
+ "rowLens |=" >> {
+ (rowLens |= Set(Cell(2, "data1"))).run(Row(1)(Set(Cell(1, "data"), Cell(2, "data1")))) mustEqual
+ (Row(1)(Set(Cell(1, "data"), Cell(2, "data1"))),Set(Cell(1, "data"), Cell(2, "data1")))
+
+ (rowLens |= Set(Cell(2, "data1"))).run(Row(1)(Set(Cell(1, "data"), Cell(2, "data2")))) mustEqual
+ (Row(1)
+ (Set(Cell(1, "data"), Cell(2, "data2"), Cell(2, "data1"))),
+ Set(Cell(1, "data"), Cell(2, "data2"), Cell(2, "data1")))
+ }
+ "rowLens -=" >> {
+ (rowLens -= Cell(2, "data1")).run(Row(1)(Set(Cell(1, "data"), Cell(2, "data1")))) mustEqual
+ (Row(1)(Set(Cell(1, "data"))), Set(Cell(1, "data")))
+ }
+ }
+}
@@ -15,7 +15,7 @@ import scalaz.scalacheck.ScalaCheckBinding._
import Arbitrary._
-class PoiSpec extends SpecificationWithJUnit with ScalaCheck {
+class PoiSpec extends Specification with ScalaCheck {
"Poi" should {
"create workbook" in {
val io = Workbook {

0 comments on commit 1b76721

Please sign in to comment.