         ]
 
         for expectedPassword: String in expectedValues {
+            XCTAssertEqualObjects(token.password(), expectedPassword, "The generator did not produce the expected OTP.")
             token = token.updatedToken()
-            XCTAssertEqualObjects(token.password(), expectedPassword, "The generator did not produce the expected OTP.")
         }
     }
 

    // https://tools.ietf.org/html/rfc6238#appendix-B
    func testTOTPRFCValues() {
        let secretKeys = [
            OTPAlgorithm.SHA1:   "12345678901234567890",
            OTPAlgorithm.SHA256: "12345678901234567890123456789012",
            OTPAlgorithm.SHA512: "1234567890123456789012345678901234567890123456789012345678901234",
        ]

        let times: Array<NSTimeInterval> = [

import OneTimePassword

class TokenGenerationTests: XCTestCase {
    // The values in this test are found in Appendix D of the HOTP RFC
    // https://tools.ietf.org/html/rfc4226#appendix-D
    func testHOTPRFCValues() {
        let secret = "12345678901234567890".dataUsingEncoding(NSASCIIStringEncoding)
        var token = Token(type: .Counter, secret: secret, algorithm: .SHA1, digits: 6)

        XCTAssertEqualObjects("755224", token.passwordForCounter(0), "The 0th OTP should be the expected string.")
        XCTAssertEqualObjects("755224", token.passwordForCounter(0), "The passwordForCounter(counter:) function should be idempotent.")

        let expectedValues = [
            "287082",
