Move History

Fork Selected
  • Tips & Tricks
    Code
    func printRandomNumber(in range: ClosedRange<Int>) {
      print(Int.random(in: range))
    }
    Test Cases
    import XCTest
    // XCTest Spec Example:
    // TODO: replace with your own tests (TDD), these are just how-to examples to get you started
    
    class SolutionTest: XCTestCase {
        static var allTests = [
            ("Test Example", testExample),
        ]
    
        func testExample() {
            printRandomNumber(in: 0 ... 100)
        }
    }
    
    XCTMain([
        testCase(SolutionTest.allTests)
    ])
  • Code
    • import Glibc
    • for count in 1...20 {
    • print(random() % 100)
    • func printRandomNumber(in range: ClosedRange<Int>) {
    • print(Int.random(in: range))
    • }
    Test Cases
    • import XCTest
    • // XCTest Spec Example:
    • // TODO: replace with your own tests (TDD), these are just how-to examples to get you started
    • class SolutionTest: XCTestCase {
    • static var allTests = [
    • ("Test Example", testExample),
    • ]
    • func testExample() {
    • printRandomNumber(in: 0 ... 100)
    • }
    • }
    • XCTMain([
    • testCase(SolutionTest.allTests)
    • ])