<commit_before>//
//  DatabaseReceiptsDatesTest.swift
//  SmartReceiptsTests
//
//  Created by <NAME> on 03/10/2018.
//  Copyright © 2018 <NAME>. All rights reserved.
//

import XCTest
@testable import SmartReceipts

class DatabaseReceiptsDatesTest: SmartReceiptsTestsBase {
    
    var testTrip: WBTrip!

    override func setUp() {
        super.setUp()
        testTrip = db.createTestTrip()
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate().addingDays(-1)])
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate().addingDays(-1)])
        
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate()])
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate()])
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate()])
    }

    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
    }

    func testMaxSecondsYesterday() {
        let date = NSDate()
        let maxSeconds = db.maxSecondForReceipts(in: testTrip, on: date.addingDays(-1))
        XCTAssertEqual(date.secondsOfDay(), maxSeconds, accuracy: 1)
    }
    
    func testMaxSecondsToday() {
        let date = NSDate()
        let maxSeconds = db.maxSecondForReceipts(in: testTrip, on: date as Date)
        XCTAssertEqual(date.secondsOfDay(), maxSeconds, accuracy: 1)
    }

}<commit_msg>Added a timing buffer to our timed database tests<commit_after>//
//  DatabaseReceiptsDatesTest.swift
//  SmartReceiptsTests
//
//  Created by <NAME> on 03/10/2018.
//  Copyright © 2018 <NAME>. All rights reserved.
//

import XCTest
@testable import SmartReceipts

class DatabaseReceiptsDatesTest: SmartReceiptsTestsBase {
    
    // Defines the accuracy buffer for these tests to avoid failures related to slower build times
    let accuracyBuffer = TimeInterval(10)
    
    var testTrip: WBTrip!

    override func setUp() {
        super.setUp()
        testTrip = db.createTestTrip()
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate().addingDays(-1)])
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate().addingDays(-1)])
        
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate()])
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate()])
        db.insertTestReceipt([ReceiptsTable.Column.ParentId : self.testTrip, ReceiptsTable.Column.Date : NSDate()])
    }

    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
    }

    func testMaxSecondsYesterday() {
        let date = NSDate()
        let maxSeconds = db.maxSecondForReceipts(in: testTrip, on: date.addingDays(-1))
        XCTAssertEqual(date.secondsOfDay(), maxSeconds, accuracy: accuracyBuffer)
    }
    
    func testMaxSecondsToday() {
        let date = NSDate()
        let maxSeconds = db.maxSecondForReceipts(in: testTrip, on: date as Date)
        XCTAssertEqual(date.secondsOfDay(), maxSeconds, accuracy: accuracyBuffer)
    }

}
{'fraction_non_alphanumeric': 0.10718390804597701, 'fraction_numerical': 0.009770114942528735, 'mean_word_length': 3.3403990024937658, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6027586', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1091, 'n_words': 236}