<commit_before>//
//  TodayKitTests.swift
//  TodayKitTests
//
//  Created by UetaMasamichi on 2016/01/24.
//  Copyright © 2016年 <NAME>. All rights reserved.
//

import XCTest
@testable import TodayKit

class TodayKitTests: XCTestCase {
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    //MARK: - Utilities
    func testFrameworkBundle() {
        
        let todayKitBundle = frameworkBundle("TodayKit.framework")
        XCTAssertNotNil(todayKitBundle)
        
        let nilBundle = frameworkBundle("This framework does not exists")
        XCTAssertNil(nilBundle)
        
    }
    
    func testDistanceBetweenPoints() {
        let point1 = CGPoint(x: 0, y: 0)
        let point2 = CGPoint(x: 3, y: 4)
        
        XCTAssertEqual(distanceBetween(point1, p2: point2), 5)

    }
    
    func testNumberOfDaysUntilDateTime() {
        
        let now = NSDate()
        let nextDay = NSDate(timeInterval: 60*60*24, sinceDate: now)
        
        XCTAssertEqual(now.numberOfDaysUntilDateTime(nextDay), 1)
        
        let sameDay = NSDate(timeInterval: 0, sinceDate: now)
        XCTAssertEqual(sameDay.numberOfDaysUntilDateTime(now), 0)
        
        
    }
    
}
<commit_msg>#20 Add test case<commit_after>//
//  TodayKitTests.swift
//  TodayKitTests
//
//  Created by UetaMasamichi on 2016/01/24.
//  Copyright © 2016年 <NAME>. All rights reserved.
//

import XCTest
@testable import TodayKit

class TodayKitTests: XCTestCase {
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    //MARK: - Utilities
    func testFrameworkBundle() {
        
        let todayKitBundle = NSBundle.frameworkBundle("TodayKit.framework")
        XCTAssertNotNil(todayKitBundle)
        
        let nilBundle = NSBundle.frameworkBundle("This framework does not exists")
        XCTAssertNil(nilBundle)
        
    }
    
    func testDistanceBetweenPoints() {
        let point1 = CGPoint(x: 0, y: 0)
        let point2 = CGPoint(x: 3, y: 4)
        
        XCTAssertEqual(CGPoint.distanceBetween(point1, p2: point2), 5)

    }
    
    func testNumberOfDaysUntilDateTime() {

        let now = NSDate()
        let nextDay = NSDate(timeInterval: 60*60*24, sinceDate: now)
        
        XCTAssertEqual(now.numberOfDaysUntilDateTime(nextDay), 1)
        
        let sameDay = NSDate(timeInterval: 0, sinceDate: now)
        XCTAssertEqual(sameDay.numberOfDaysUntilDateTime(now), 0)
        
        guard let nextDayFromCalendar = NSCalendar.currentCalendar().dateByAddingUnit(.Day, value: 1, toDate: now, options: []) else {
            fatalError()
        }
        
        XCTAssertEqual(now.numberOfDaysUntilDateTime(nextDayFromCalendar), 1)

        let components1 = NSDateComponents()
        components1.year = 2016
        components1.month = 10
        components1.day = 10
        components1.hour = 23
        components1.minute = 59
        
        guard let date1 = NSCalendar.currentCalendar().dateFromComponents(components1) else {
            fatalError()
        }
        
        let components2 = NSDateComponents()
        components2.year = 2016
        components2.month = 10
        components2.day = 11
        components2.hour = 0
        components2.minute = 0
        
        guard let date2 = NSCalendar.currentCalendar().dateFromComponents(components2) else {
            fatalError()
        }
        
        XCTAssertEqual(date1.numberOfDaysUntilDateTime(date2), 1)
        
    }
    
    func testNextWeekDatesFromDate() {
        
        let components1 = NSDateComponents()
        components1.year = 2016
        components1.month = 4
        components1.day = 9
        
        guard let date1 = NSCalendar.currentCalendar().dateFromComponents(components1) else {
            fatalError()
        }
        
        let dates1 = NSDate.nextWeekDatesFromDate(date1)
        
        XCTAssertEqual(dates1.count, 7)
    
        guard let lastDate1 = dates1.last else {
            fatalError()
        }
        
        let lastDate1Component = NSCalendar.currentCalendar().components([.Year, .Month, .Day], fromDate: lastDate1)
        XCTAssertEqual(lastDate1Component.day, 15)
        
        let components2 = NSDateComponents()
        components2.year = 2016
        components2.month = 4
        components2.day = 29
        
        guard let date2 = NSCalendar.currentCalendar().dateFromComponents(components2) else {
            fatalError()
        }
        
        let dates2 = NSDate.nextWeekDatesFromDate(date2)
        
        guard let lastDate2 = dates2.last else {
            fatalError()
        }
        
        let lastDate2Component = NSCalendar.currentCalendar().components([.Year, .Month, .Day], fromDate: lastDate2)
        XCTAssertEqual(lastDate2Component.day, 5)
        
    }
    
    func testPreviousWeekDatesFromDate() {
        
        let components1 = NSDateComponents()
        components1.year = 2016
        components1.month = 4
        components1.day = 9
        
        guard let date1 = NSCalendar.currentCalendar().dateFromComponents(components1) else {
            fatalError()
        }
        
        let dates1 = NSDate.previousWeekDatesFromDate(date1)
        
        XCTAssertEqual(dates1.count, 7)
        
        guard let lastDate1 = dates1.first else {
            fatalError()
        }
        
        let lastDate1Component = NSCalendar.currentCalendar().components([.Year, .Month, .Day], fromDate: lastDate1)
        XCTAssertEqual(lastDate1Component.day, 3)
        
        let components2 = NSDateComponents()
        components2.year = 2016
        components2.month = 5
        components2.day = 5
        
        guard let date2 = NSCalendar.currentCalendar().dateFromComponents(components2) else {
            fatalError()
        }
        
        let dates2 = NSDate.previousWeekDatesFromDate(date2)
        
        guard let lastDate2 = dates2.first else {
            fatalError()
        }
        
        let lastDate2Component = NSCalendar.currentCalendar().components([.Year, .Month, .Day], fromDate: lastDate2)
        XCTAssertEqual(lastDate2Component.day, 29)
    }
    
}

{'fraction_non_alphanumeric': 0.08338278931750742, 'fraction_numerical': 0.028783382789317507, 'mean_word_length': 2.0283018867924527, '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': '3809482', 'n_tokens_mistral': 2035, 'n_tokens_neox': 1913, 'n_words': 440}