From ab81347b22617d5a9e79430e8a4598d7b8a95548 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 17 Mar 2024 16:38:47 +0100 Subject: [PATCH] Implemented the "bitBucket" static constant for the URL+Constants extension in the Foundation library. --- .../Sources/Extensions/URL+Constants.swift | 29 +++++++++++++++++++ .../Extensions/String+ConstantsTests.swift | 4 +-- .../Tests/Extensions/URL+ConstantsTests.swift | 27 +++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 Libraries/Foundation/Kit/Sources/Extensions/URL+Constants.swift create mode 100644 Libraries/Foundation/Test/Tests/Extensions/URL+ConstantsTests.swift diff --git a/Libraries/Foundation/Kit/Sources/Extensions/URL+Constants.swift b/Libraries/Foundation/Kit/Sources/Extensions/URL+Constants.swift new file mode 100644 index 0000000..24bb24c --- /dev/null +++ b/Libraries/Foundation/Kit/Sources/Extensions/URL+Constants.swift @@ -0,0 +1,29 @@ +// +// URL+Constants.swift +// ReviewsFoundationKit +// +// Created by Javier Cicchelli on 17/03/2024. +// Copyright © 2024 Röck+Cöde VoF. All rights reserved. +// + +import Foundation + +extension URL { + + // MARK: Constants + public static let bitBucket: URL = { + if #available(iOS 16.0, *) { + .init(filePath: .FilePath.bitBucket) + } else { + .init(fileURLWithPath: .FilePath.bitBucket) + } + }() + +} + +// MARK: - String+Constants +private extension String { + enum FilePath { + static let bitBucket = "/dev/null" + } +} diff --git a/Libraries/Foundation/Test/Tests/Extensions/String+ConstantsTests.swift b/Libraries/Foundation/Test/Tests/Extensions/String+ConstantsTests.swift index fcd80c7..cbbbbd0 100644 --- a/Libraries/Foundation/Test/Tests/Extensions/String+ConstantsTests.swift +++ b/Libraries/Foundation/Test/Tests/Extensions/String+ConstantsTests.swift @@ -6,7 +6,7 @@ // Copyright © 2024 Röck+Cöde VoF. All rights reserved. // -import ReviewsFoundation +import ReviewsFoundationKit import XCTest final class String_ConstantsTests: XCTestCase { @@ -15,7 +15,7 @@ final class String_ConstantsTests: XCTestCase { private var sut: String! // MARK: Constants tests - func testEmpty() throws { + func testEmpty() { // GIVEN sut = .empty diff --git a/Libraries/Foundation/Test/Tests/Extensions/URL+ConstantsTests.swift b/Libraries/Foundation/Test/Tests/Extensions/URL+ConstantsTests.swift new file mode 100644 index 0000000..91167b5 --- /dev/null +++ b/Libraries/Foundation/Test/Tests/Extensions/URL+ConstantsTests.swift @@ -0,0 +1,27 @@ +// +// URL+ConstantsTests.swift +// ReviewsFoundationTest +// +// Created by Javier Cicchelli on 17/03/2024. +// Copyright © 2024 Röck+Cöde VoF. All rights reserved. +// + +import Foundation +import ReviewsFoundationKit +import XCTest + +final class URL_ConstantsTests: XCTestCase { + + // MARK: Properties + private var sut: URL! + + // MARK: Constants tests + func testBitBucket() { + sut = .bitBucket + + // WHEN + // THEN + XCTAssertEqual(sut.absoluteString, "file:///dev/null") + } + +}