Skip to content

Commit

Permalink
Catch OOM and consider it a pass (twitter#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnynek authored Jan 13, 2017
1 parent 1be041f commit f1147b4
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ class SpaceSaverLaws extends CheckProperties {

property("SpaceSaver.fromBytes yield a failure on bad Array[Byte]") {
forAll { a: Array[Byte] =>
val fromBytes = SpaceSaver.fromBytes(a, SpaceSaverTest.arrayByteToString)
//We check that `fromBytes` doesn't yield exceptions
fromBytes.isFailure || fromBytes.isSuccess
try {
val fromBytes = SpaceSaver.fromBytes(a, SpaceSaverTest.arrayByteToString)
//We check that `fromBytes` doesn't yield exceptions
fromBytes.isFailure || fromBytes.isSuccess
} catch {
case oom: OutOfMemoryError => true // this happens if random data has a giant number in it
}
}
}
}
Expand Down Expand Up @@ -100,4 +104,4 @@ object SpaceSaverTest {

def arrayByteToString(a: Array[Byte]): Try[String] = Try(new String(a, "UTF-8"))

}
}

0 comments on commit f1147b4

Please sign in to comment.