[Enhancement] Optional+Nil extension #17

Merged
javier merged 3 commits from enhancement/optional_nil into main 2023-05-06 21:19:40 +00:00
2 changed files with 8 additions and 11 deletions
Showing only changes of commit 61a49da3ef - Show all commits

View File

@ -12,17 +12,14 @@
public extension String {
// MARK: Properties
// MARK: Constants
/// Represents an empty string.
/// A string that represents an empty string.
static let empty = ""
// MARK: Functions
// MARK: Properties
/// Checks whether a string is not empty.
/// - Returns: A boolean value that represents whether the string is not empty.
func isNotEmpty() -> Bool {
isEmpty == false
}
/// A Boolean value indicating whether a string is not empty.
var isNotEmpty: Bool { !isEmpty }
}

View File

@ -31,7 +31,7 @@ final class String_EmptyTests: XCTestCase {
let string = String.empty
// WHEN
let result = string.isNotEmpty()
let result = string.isNotEmpty
// THEN
XCTAssertFalse(result)
@ -42,7 +42,7 @@ final class String_EmptyTests: XCTestCase {
let string = String.Test.string
// WHEN
let result = string.isNotEmpty()
let result = string.isNotEmpty
// THEN
XCTAssertTrue(result)