浏览代码

Tests lipsticks

Marcin Krzyżanowski 7 年之前
父节点
当前提交
8906c089b9

+ 4 - 4
Tests/CryptoSwiftTests/AESTests.swift

@@ -364,9 +364,9 @@ final class AESTests: XCTestCase {
             let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
             let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
             let aes = try! AES(key: key, blockMode: .CBC(iv: iv), padding: .pkcs7)
-            measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: true, for: { () -> Void in
+            measure {
                 _ = try! aes.encrypt(message)
-            })
+            }
         }
 
         func testAESDecryptPerformance() {
@@ -374,9 +374,9 @@ final class AESTests: XCTestCase {
             let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
             let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
             let aes = try! AES(key: key, blockMode: .CBC(iv: iv), padding: .pkcs7)
-            measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: true, for: { () -> Void in
+            measure {
                 _ = try! aes.decrypt(message)
-            })
+            }
         }
     }
 #endif

+ 1 - 1
Tests/CryptoSwiftTests/ChaCha20Tests.swift

@@ -108,7 +108,7 @@ final class ChaCha20Tests: XCTestCase {
         func testChaCha20Performance() {
             let key: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f]
             let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
-            let message = Array<UInt8>(repeating: 7, count: 1024)
+            let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
             measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: true, for: { () -> Void in
                 do {
                     _ = try ChaCha20(key: key, iv: iv).encrypt(message)

+ 3 - 3
Tests/CryptoSwiftTests/PBKDF.swift

@@ -49,16 +49,16 @@ class PBKDF: XCTestCase {
         let password: Array<UInt8> = "s33krit".bytes
         let salt: Array<UInt8> = "nacl".bytes
         let value = try! PKCS5.PBKDF2(password: password, salt: salt, iterations: 2, keyLength: 8, variant: .sha1).calculate()
-        XCTAssert(value.toHexString() == "a53cf3df485e5cd9", "PBKDF2 fail")
+        XCTAssertEqual(value.toHexString(), "a53cf3df485e5cd9")
     }
 
     #if !CI
         func testPerformance() {
             let password: Array<UInt8> = "s33krit".bytes
             let salt: Array<UInt8> = "nacl".bytes
-            measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: true, for: { () -> Void in
+            measure {
                 _ = try! PKCS5.PBKDF2(password: password, salt: salt, iterations: 65536, keyLength: 32, variant: .sha1).calculate()
-            })
+            }
         }
     #endif
 

+ 3 - 5
Tests/CryptoSwiftTests/RabbitTests.swift

@@ -117,11 +117,9 @@ class RabbitTests: XCTestCase {
             let key: Array<UInt8> = Array<UInt8>(repeating: 0, count: Rabbit.keySize)
             let iv: Array<UInt8> = Array<UInt8>(repeating: 0, count: Rabbit.ivSize)
             let message = Array<UInt8>(repeating: 7, count: (1024 * 1024) * 1)
-            measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: true, for: { () -> Void in
-                let encrypted = try! Rabbit(key: key, iv: iv).encrypt(message)
-                self.stopMeasuring()
-                XCTAssert(!encrypted.isEmpty, "not encrypted")
-            })
+            measure {
+                _ = try! Rabbit(key: key, iv: iv).encrypt(message)
+            }
         }
     }
 #endif