Commit b69950f8 authored by Drew's avatar Drew

Fix an overflow bug in random snark

parent e7ef89e6
......@@ -62,15 +62,15 @@ public class CarolineCoreEngine : CarolineEngine {
print("-----------------------")
#if !swift(>=2.3) || os(Linux)
srand(UInt32(time(nil)))
let rand_int = rand()
let rand_int = Int(rand() % UInt32(Int.max))
#else
let rand_int = arc4random()
let rand_int = Int(arc4random())
#endif
if failures == 0 {
print(passSnark[Int(rand_int) % passSnark.count])
print(passSnark[rand_int % passSnark.count])
}
else {
print(failSnark[Int(rand_int) % failSnark.count])
print(failSnark[rand_int % failSnark.count])
}
print("Test execution finished with \(tests.count) tests, \(failures) failures, \(skipped) skipped.")
if failures > 0 { return false }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment