Sfoglia il codice sorgente

Placed throwing methods within a do catch block, with an XCTFail error message.

Brandon Toms 3 anni fa
parent
commit
d660b624fb
1 ha cambiato i file con 9 aggiunte e 5 eliminazioni
  1. 9 5
      Tests/CryptoSwiftTests/RSATests.swift

+ 9 - 5
Tests/CryptoSwiftTests/RSATests.swift

@@ -182,12 +182,16 @@ final class RSATests: XCTestCase {
       0x11, 0x22, 0x33, 0x44
       0x11, 0x22, 0x33, 0x44
     ]
     ]
     
     
-    let rsa = RSA(keySize: 2048)
-    // Sometimes the modulus size is 2047 bits, but it's okay (with two 1024 bits primes)
-    //XCTAssertEqual(rsa.keySize, 2048, "key size is not correct")
+    do {
+      let rsa = try RSA(keySize: 2048)
+      // Sometimes the modulus size is 2047 bits, but it's okay (with two 1024 bits primes)
+      //XCTAssertEqual(rsa.keySize, 2048, "key size is not correct")
     
     
-    let decrypted = try! rsa.decrypt(try! rsa.encrypt(message))
-    XCTAssertEqual(decrypted, message, "encrypt+decrypt failed")
+      let decrypted = try rsa.decrypt(rsa.encrypt(message))
+      XCTAssertEqual(decrypted, message, "encrypt+decrypt failed")
+    } catch {
+      XCTFail(error.localizedDescription)
+    }
   }
   }
 
 
 }
 }