Basic unit test for unadvanced Rotor
This commit is contained in:
parent
56ae8cc5bb
commit
31774fbc07
1 changed files with 22 additions and 0 deletions
|
@ -7,6 +7,8 @@
|
|||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Enigma
|
||||
|
||||
|
||||
class EnigmaTests: XCTestCase {
|
||||
|
||||
|
@ -33,3 +35,23 @@ class EnigmaTests: XCTestCase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class RotorTests: XCTestCase {
|
||||
let rotorSeries = "EKMFLGDQVZNTOWYHXUSPAIBRCJ"
|
||||
var rotor: Enigma.Rotor!
|
||||
|
||||
override func setUp() {
|
||||
rotor = try! Enigma.Rotor(series: rotorSeries)
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
rotor = nil
|
||||
}
|
||||
|
||||
func testThatUnadvancedSubstitutionWorks() {
|
||||
for (plainCharacter, cipherCharacter) in zip("ABCDEFGHIJKLMNOPQRSTUVWXYZ".characters, rotorSeries.characters) {
|
||||
XCTAssertEqual(try! rotor.encode(plainCharacter), cipherCharacter)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue