mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 15:50:17 +01:00
Write CalendarExtensionsTests.
This commit is contained in:
parent
5ec78cbbde
commit
0ec83de1de
@ -0,0 +1,39 @@
|
||||
//
|
||||
// CalendarExtensionsTests.swift
|
||||
//
|
||||
//
|
||||
// Created by Brent Simmons on 5/18/24.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
final class CalendarExtensionsTests: XCTestCase {
|
||||
|
||||
// MARK: - Test dateIsToday
|
||||
|
||||
func testDateIsToday() {
|
||||
|
||||
var date = Date()
|
||||
// The below could fail if midnight hits between the above line and the following line! This will probably never happen, but if it does, check to see if this was run at midnight.
|
||||
XCTAssertTrue(Calendar.dateIsToday(date))
|
||||
|
||||
date = Date.distantPast
|
||||
XCTAssertFalse(Calendar.dateIsToday(date))
|
||||
|
||||
date = Date.distantFuture
|
||||
XCTAssertFalse(Calendar.dateIsToday(date))
|
||||
|
||||
date = Date().byAdding(days: 14)
|
||||
XCTAssertFalse(Calendar.dateIsToday(date))
|
||||
|
||||
date = Date().bySubtracting(days: 67)
|
||||
XCTAssertFalse(Calendar.dateIsToday(date))
|
||||
|
||||
let calendar = Calendar.current
|
||||
let yesterday = calendar.date(byAdding: .day, value: -1, to: Date())!
|
||||
XCTAssertFalse(Calendar.dateIsToday(yesterday))
|
||||
|
||||
let tomorrow = calendar.date(byAdding: .day, value: 1, to: Date())!
|
||||
XCTAssertFalse(Calendar.dateIsToday(tomorrow))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user