diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/scala/xyz/driver/core/database/DatabaseTest.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/core/database/DatabaseTest.scala b/src/test/scala/xyz/driver/core/database/DatabaseTest.scala index a5c65ea..f85dcad 100644 --- a/src/test/scala/xyz/driver/core/database/DatabaseTest.scala +++ b/src/test/scala/xyz/driver/core/database/DatabaseTest.scala @@ -17,12 +17,27 @@ class DatabaseTest extends FlatSpec with Matchers with Checkers { val validLength = nextInt(10) val valid = nextToken(validLength) + val validOp = Some(valid) val invalid = nextToken(validLength + nextInt(10, 1)) + val invalidOp = Some(invalid) def mapper(s: String): Option[String] = if (s.length == validLength) Some(s) else None TestConverter.fromStringOrThrow(valid, mapper, valid) should be(valid) + TestConverter.expectValid(mapper, valid) should be(valid) + + TestConverter.expectExistsAndValid(mapper, validOp) should be(valid) + + TestConverter.expectValidOrEmpty(mapper, validOp) should be(Some(valid)) + TestConverter.expectValidOrEmpty(mapper, None) should be(None) + an[DatabaseException] should be thrownBy TestConverter.fromStringOrThrow(invalid, mapper, invalid) + + an[DatabaseException] should be thrownBy TestConverter.expectValid(mapper, invalid) + + an[DatabaseException] should be thrownBy TestConverter.expectExistsAndValid(mapper, invalidOp) + + an[DatabaseException] should be thrownBy TestConverter.expectValidOrEmpty(mapper, invalidOp) } } |