Skip to content

Commit

Permalink
Faster generation of random numbers for testcases fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mw99 committed Mar 7, 2019
1 parent 9b923e8 commit 9b589b1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Tests/DataCompressionTests/CompressionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ class CompressionTest: XCTestCase
func testRandomDataChunks()
{
for i in 1...500 {
let ints = [UInt32](repeating: 0, count: i).map { _ in arc4random() }
let ints = [UInt32](repeating: 0, count: 1 + (i / 4)).map { _ in arc4random() }
let data = Data(bytes: ints, count: i)
XCTAssertEqual(data, comp(data), "Fails with random data :(")
XCTAssertEqual(data, comp(data), "Fails with random data (\(data.count) bytes) :(")
}
}

func testRandomDataBlob()
{
let b = 1024 * 1024 * 15 // 15 MB
let ints = [UInt32](repeating: 0, count: b / 4).map { _ in arc4random() }
let data = Data(bytes: ints, count: b / 4)
XCTAssertEqual(data, comp(data), "Fails with random data (\(b) bytes) :(")
let data = Data(bytes: ints, count: b)
XCTAssertEqual(data, comp(data), "Fails with random data large blob of 15 MB :(")
}

func comp(_ d: Data?) -> Data?
Expand Down

0 comments on commit 9b589b1

Please sign in to comment.