<commit_before>//
//  SRSDataItemTests.swift
//  WaniKaniKit
//
//  Copyright © 2015 <NAME>. All rights reserved.
//

import XCTest
@testable import WaniKaniKit

class SRSDataItemTests: XCTestCase {
    
    func testGuruDateLockedKanji() {
        let locked = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4)
        
        let lockedGuruDate = locked.guruDate(date(2016, 1, 1, 0, 0, 0))
        let lockedExpectedGuruDate = date(2016, 1, 5, 10, 0, 0)
        XCTAssertEqual(lockedGuruDate, lockedExpectedGuruDate)
    }
    
    func testGuruDateApprenticeKanji() {
        let newlyUnlocked = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: 1,
                dateUnlocked: date(2016, 1, 1, 0, 0, 0),
                dateAvailable: date(2016, 2, 1, 0, 0, 0),
                burned: false))
        
        let newlyUnlockedGuruDate = newlyUnlocked.guruDate(nil)
        let newlyUnlockedExpectedGuruDate = date(2016, 2, 5, 6, 0, 0)
        XCTAssertEqual(newlyUnlockedGuruDate, newlyUnlockedExpectedGuruDate)
    }
    
    func testGuruDateApprentice3Kanji() {
        let nearlyGuru = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: SRSLevel.Guru.numericLevelThreshold - 1,
                dateUnlocked: date(2016, 1, 1, 0, 0, 0),
                dateAvailable: date(2016, 2, 1, 0, 0, 0),
                burned: false))
        
        let nearlyGuruDate = nearlyGuru.guruDate(nil)
        let nearlyGuruExpectedDate = date(2016, 2, 1, 0, 0, 0)
        XCTAssertEqual(nearlyGuruDate, nearlyGuruExpectedDate)
    }
    
    func testGuruDateMasterKanji() {
        let mastered = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Master,
                srsLevelNumeric: SRSLevel.Master.numericLevelThreshold,
                dateUnlocked: date(2016, 1, 1, 0, 0, 0),
                dateAvailable: date(2016, 2, 1, 0, 0, 0),
                burned: false))
        
        let masteredGuruDate = mastered.guruDate(nil)
        let masteredExpectedGuruDate: NSDate? = nil
        XCTAssertEqual(masteredGuruDate, masteredExpectedGuruDate)
    }
    
    func testGuruDateLockedAcceleratedRadical() {
        let locked = Radical(meaning: "", level: 1)
        
        let lockedGuruDate = locked.guruDate(date(2016, 1, 1, 0, 0, 0))
        let lockedExpectedGuruDate = date(2016, 1, 2, 13, 0, 0)
        XCTAssertEqual(lockedGuruDate, lockedExpectedGuruDate)
    }
    
    func testGuruDateLockedNonAcceleratedRadical() {
        let locked = Radical(meaning: "", level: 3)
        
        let lockedGuruDate = locked.guruDate(date(2016, 1, 1, 0, 0, 0))
        let lockedExpectedGuruDate = date(2016, 1, 4, 10, 0, 0)
        XCTAssertEqual(lockedGuruDate, lockedExpectedGuruDate)
    }
    
    func testGuruDateApprenticeAcceleratedRadical() {
        let newlyUnlocked = Radical(meaning: "",
            level: 1,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: 1,
                dateUnlocked: date(2016, 1, 1, 0, 0, 0),
                dateAvailable: date(2016, 2, 1, 0, 0, 0),
                burned: false))
        
        let newlyUnlockedGuruDate = newlyUnlocked.guruDate(nil)
        let newlyUnlockedExpectedGuruDate = date(2016, 2, 2, 11, 0, 0)
        XCTAssertEqual(newlyUnlockedGuruDate, newlyUnlockedExpectedGuruDate)
    }
    
    func testGuruDateApprenticeNonAcceleratedRadical() {
        let newlyUnlocked = Radical(meaning: "",
            level: 10,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: 1,
                dateUnlocked: date(2016, 1, 1, 0, 0, 0),
                dateAvailable: date(2016, 2, 1, 0, 0, 0),
                burned: false))
        
        let newlyUnlockedGuruDate = newlyUnlocked.guruDate(nil)
        let newlyUnlockedExpectedGuruDate = date(2016, 2, 4, 6, 0, 0)
        XCTAssertEqual(newlyUnlockedGuruDate, newlyUnlockedExpectedGuruDate)
    }
    
    func testEarliestPossibleGuruDateLockedKanji() {
        let locked = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4)
        
        let lockedGuruDate = locked.earliestPossibleGuruDate(date(2016, 1, 1, 0, 0, 0))
        let lockedExpectedGuruDate = date(2016, 1, 5, 10, 0, 0)
        XCTAssertEqual(lockedGuruDate, lockedExpectedGuruDate)
    }
    
    func testEarliestPossibleGuruDateApprenticeKanji() {
        let newlyUnlocked = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: 1,
                dateUnlocked: date(2016, 1, 1, 0, 0, 0),
                dateAvailable: date(2016, 2, 1, 0, 0, 0),<commit_msg>Fix tests - available dates must be in the future for them to be predictable<commit_after>//
//  SRSDataItemTests.swift
//  WaniKaniKit
//
//  Copyright © 2015 <NAME>. All rights reserved.
//

import XCTest
@testable import WaniKaniKit

class SRSDataItemTests: XCTestCase {
    
    func testGuruDateLockedKanji() {
        let locked = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4)
        
        let lockedGuruDate = locked.guruDate(date(2016, 1, 1, 0, 0, 0))
        let lockedExpectedGuruDate = date(2016, 1, 5, 10, 0, 0)
        XCTAssertEqual(lockedGuruDate, lockedExpectedGuruDate)
    }
    
    func testGuruDateApprenticeKanji() {
        let newlyUnlocked = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: 1,
                dateUnlocked: date(2020, 1, 1, 0, 0, 0),
                dateAvailable: date(2020, 2, 1, 0, 0, 0),
                burned: false))
        
        let newlyUnlockedGuruDate = newlyUnlocked.guruDate(nil)
        let newlyUnlockedExpectedGuruDate = date(2020, 2, 5, 6, 0, 0)
        XCTAssertEqual(newlyUnlockedGuruDate, newlyUnlockedExpectedGuruDate)
    }
    
    func testGuruDateApprentice3Kanji() {
        let nearlyGuru = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: SRSLevel.Guru.numericLevelThreshold - 1,
                dateUnlocked: date(2016, 1, 1, 0, 0, 0),
                dateAvailable: date(2020, 2, 1, 0, 0, 0),
                burned: false))
        
        let nearlyGuruDate = nearlyGuru.guruDate(nil)
        let nearlyGuruExpectedDate = date(2020, 2, 1, 0, 0, 0)
        XCTAssertEqual(nearlyGuruDate, nearlyGuruExpectedDate)
    }
    
    func testGuruDateMasterKanji() {
        let mastered = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Master,
                srsLevelNumeric: SRSLevel.Master.numericLevelThreshold,
                dateUnlocked: date(2016, 1, 1, 0, 0, 0),
                dateAvailable: date(2020, 2, 1, 0, 0, 0),
                burned: false))
        
        let masteredGuruDate = mastered.guruDate(nil)
        let masteredExpectedGuruDate: NSDate? = nil
        XCTAssertEqual(masteredGuruDate, masteredExpectedGuruDate)
    }
    
    func testGuruDateLockedAcceleratedRadical() {
        let locked = Radical(meaning: "", level: 1)
        
        let lockedGuruDate = locked.guruDate(date(2016, 1, 1, 0, 0, 0))
        let lockedExpectedGuruDate = date(2016, 1, 2, 13, 0, 0)
        XCTAssertEqual(lockedGuruDate, lockedExpectedGuruDate)
    }
    
    func testGuruDateLockedNonAcceleratedRadical() {
        let locked = Radical(meaning: "", level: 3)
        
        let lockedGuruDate = locked.guruDate(date(2016, 1, 1, 0, 0, 0))
        let lockedExpectedGuruDate = date(2016, 1, 4, 10, 0, 0)
        XCTAssertEqual(lockedGuruDate, lockedExpectedGuruDate)
    }
    
    func testGuruDateApprenticeAcceleratedRadical() {
        let newlyUnlocked = Radical(meaning: "",
            level: 1,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: 1,
                dateUnlocked: date(2020, 1, 1, 0, 0, 0),
                dateAvailable: date(2020, 2, 1, 0, 0, 0),
                burned: false))
        
        let newlyUnlockedGuruDate = newlyUnlocked.guruDate(nil)
        let newlyUnlockedExpectedGuruDate = date(2020, 2, 2, 11, 0, 0)
        XCTAssertEqual(newlyUnlockedGuruDate, newlyUnlockedExpectedGuruDate)
    }
    
    func testGuruDateApprenticeNonAcceleratedRadical() {
        let newlyUnlocked = Radical(meaning: "",
            level: 10,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: 1,
                dateUnlocked: date(2020, 1, 1, 0, 0, 0),
                dateAvailable: date(2020, 2, 1, 0, 0, 0),
                burned: false))
        
        let newlyUnlockedGuruDate = newlyUnlocked.guruDate(nil)
        let newlyUnlockedExpectedGuruDate = date(2020, 2, 4, 6, 0, 0)
        XCTAssertEqual(newlyUnlockedGuruDate, newlyUnlockedExpectedGuruDate)
    }
    
    func testEarliestPossibleGuruDateLockedKanji() {
        let locked = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4)
        
        let lockedGuruDate = locked.earliestPossibleGuruDate(date(2016, 1, 1, 0, 0, 0))
        let lockedExpectedGuruDate = date(2016, 1, 5, 10, 0, 0)
        XCTAssertEqual(lockedGuruDate, lockedExpectedGuruDate)
    }
    
    func testEarliestPossibleGuruDateApprenticeKanji() {
        let newlyUnlocked = Kanji(character: "",
            meaning: "",
            importantReading: "",
            level: 4,
            userSpecificSRSData: UserSpecificSRSData(srsLevel: SRSLevel.Apprentice,
                srsLevelNumeric: 1,
                dateUnlocked: date(2016, 1, 1, 0, 0, 0),
                dateAvailable: date(2016, 2, 1, 0, 0, 0),
{'fraction_non_alphanumeric': 0.09707558628421938, 'fraction_numerical': 0.045220966084275435, 'mean_word_length': 2.2163461538461537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4109959', 'n_tokens_mistral': 3822, 'n_tokens_neox': 3296, 'n_words': 728}