From 9b589b161cee9c24cda6dde1bdb45f0d3895709c Mon Sep 17 00:00:00 2001 From: Markus Wanke Date: Wed, 26 Apr 2017 17:31:48 +0900 Subject: [PATCH] Faster generation of random numbers for testcases fixed --- Tests/DataCompressionTests/CompressionTest.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/DataCompressionTests/CompressionTest.swift b/Tests/DataCompressionTests/CompressionTest.swift index 0f9988a..d088eb1 100644 --- a/Tests/DataCompressionTests/CompressionTest.swift +++ b/Tests/DataCompressionTests/CompressionTest.swift @@ -30,9 +30,9 @@ 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) :(") } } @@ -40,8 +40,8 @@ class CompressionTest: XCTestCase { 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?