Skip to content

Commit

Permalink
Merge pull request #3960 from allbertoMD/main
Browse files Browse the repository at this point in the history
Reto #26 - Swift
  • Loading branch information
Roswell468 authored Jun 28, 2023
2 parents 52bc16b + 812e7f0 commit 16ac38c
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Retos/Reto #26 - TESTING [Media]/swift/allbertoMD.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Foundation
import XCTest

// Se aconseja usar el script en Playground para poder usar XCTest

func isFriday13th(month: Int, year: Int) -> Bool {

let calendar = Calendar.current
var components = DateComponents()

components.year = year
components.month = month
components.day = 13

if let date = calendar.date(from: components) {
let weekday = calendar.component(.weekday, from: date)
return weekday == 6
}

return false
}

class IsFriday13thTests: XCTestCase {

func testIsFriday13th() {

XCTAssertTrue(isFriday13th(month: 8, year: 2021))
XCTAssertTrue(isFriday13th(month: 1, year: 2023))


XCTAssertFalse(isFriday13th(month: 5, year: 2023))
XCTAssertFalse(isFriday13th(month: 7, year: 2025))
}
}

IsFriday13thTests.defaultTestSuite.run()




0 comments on commit 16ac38c

Please sign in to comment.