Skip to content

Commit

Permalink
Add test for issue iheartradio#82
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippus committed Feb 14, 2021
1 parent 4d32242 commit d7b9016
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ lazy val project = Project("project", file("."))
}
}
},
unmanagedSourceDirectories in Test ++= {
(unmanagedSourceDirectories in Test).value.map { dir =>
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => file(dir.getPath ++ "-2.13+")
case _ => file(dir.getPath ++ "-2.13-")
}
}
},
libraryDependencies ++=
(if (scalaVersion.value.startsWith("2.10"))
Seq(
Expand Down
23 changes: 23 additions & 0 deletions src/test/scala-2.13+/net/ceedubs/ficus/Issue82Spec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.ceedubs.ficus

import net.ceedubs.ficus.Ficus._
import net.ceedubs.ficus.readers.ArbitraryTypeReader._
import com.typesafe.config._
import org.specs2.mutable.Specification

class Issue82Spec extends Specification {
"Ficus config" should {
"not throw `java.lang.ClassCastException`" in {
case class TestSettings(val `foo-bar`: Long, `foo`: String)
val config = ConfigFactory.parseString("""{ foo-bar: 3, foo: "4" }""")
config.as[TestSettings] must not(throwA[java.lang.ClassCastException])
}

"""should not assign "foo-bar" to "foo"""" in {
case class TestSettings(val `foo-bar`: String, `foo`: String)
val config = ConfigFactory.parseString("""{ foo-bar: "foo-bar", foo: "foo" }""")
val settings = config.as[TestSettings]
(settings.`foo-bar` mustEqual "foo-bar") and (settings.`foo` mustEqual "foo")
}
}
}

0 comments on commit d7b9016

Please sign in to comment.