Complete rename across all bundle IDs, App Groups, CloudKit containers, StoreKit product IDs, data store filenames, URL schemes, logger subsystems, Swift identifiers, user-facing strings (7 languages), file names, directory names, Xcode project, schemes, assets, and documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
64 lines
2.1 KiB
Swift
64 lines
2.1 KiB
Swift
//
|
|
// Tests_iOS.swift
|
|
// Tests iOS
|
|
//
|
|
// Created by Trey Tartt on 1/10/22.
|
|
//
|
|
|
|
import XCTest
|
|
|
|
// Local copy — UI test target cannot @testable import Reflect
|
|
private extension Date {
|
|
static func dates(from fromDate: Date, toDate: Date, includingToDate: Bool = false) -> [Date] {
|
|
var dates: [Date] = []
|
|
var date = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: fromDate)!
|
|
let toDate = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: toDate)!
|
|
|
|
if includingToDate {
|
|
while date <= toDate {
|
|
dates.append(date)
|
|
guard let newDate = Calendar.current.date(byAdding: .day, value: 1, to: date) else { break }
|
|
date = newDate
|
|
}
|
|
} else {
|
|
while date < toDate {
|
|
dates.append(date)
|
|
guard let newDate = Calendar.current.date(byAdding: .day, value: 1, to: date) else { break }
|
|
date = newDate
|
|
}
|
|
}
|
|
|
|
return dates
|
|
}
|
|
}
|
|
|
|
class Tests_iOS: XCTestCase {
|
|
override func setUpWithError() throws {
|
|
continueAfterFailure = false
|
|
}
|
|
|
|
override func tearDownWithError() throws {
|
|
}
|
|
|
|
func testDatesBetween() {
|
|
let today = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: Date())!
|
|
let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: today)!
|
|
let tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: today)!
|
|
|
|
let dates = Date.dates(from: Calendar.current.date(byAdding: .day, value: -10, to: Date())!, toDate: Date())
|
|
|
|
XCTAssertTrue(dates.last == yesterday)
|
|
XCTAssertTrue(dates.first == tenDaysAgo)
|
|
}
|
|
|
|
func testDatesIncluding() {
|
|
let today = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: Date())!
|
|
let tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: today)!
|
|
|
|
let dates = Date.dates(from: Calendar.current.date(byAdding: .day, value: -10, to: Date())!, toDate: Date(), includingToDate: true)
|
|
|
|
XCTAssertTrue(dates.last == today)
|
|
XCTAssertTrue(dates.first == tenDaysAgo)
|
|
}
|
|
}
|