blob: d7d9fe9a0e37d3d7bfbffacfe67eaa8f214f434f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import scala.util.Try
object C extends Companion[C] {
def parse(v: String) = if (v.nonEmpty) Some(new C(v)) else None
}
case class C(value: String)
object Test {
def main(args: Array[String]): Unit = {
assert(Try{C("")}.isFailure, "Empty value should fail to parse") // check that parse is used to validate input
assert(C("a").value == "a", "Unexpected value")
}
}
|