[Enhancement] Optional+Nil extension #17
@ -12,17 +12,14 @@
|
|||||||
|
|
||||||
public extension String {
|
public extension String {
|
||||||
|
|
||||||
// MARK: Properties
|
// MARK: Constants
|
||||||
|
|
||||||
/// Represents an empty string.
|
/// A string that represents an empty string.
|
||||||
static let empty = ""
|
static let empty = ""
|
||||||
|
|
||||||
// MARK: Functions
|
// MARK: Properties
|
||||||
|
|
||||||
/// Checks whether a string is not empty.
|
/// A Boolean value indicating whether a string is not empty.
|
||||||
/// - Returns: A boolean value that represents whether the string is not empty.
|
var isNotEmpty: Bool { !isEmpty }
|
||||||
func isNotEmpty() -> Bool {
|
|
||||||
isEmpty == false
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ final class String_EmptyTests: XCTestCase {
|
|||||||
let string = String.empty
|
let string = String.empty
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
let result = string.isNotEmpty()
|
let result = string.isNotEmpty
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
XCTAssertFalse(result)
|
XCTAssertFalse(result)
|
||||||
@ -42,7 +42,7 @@ final class String_EmptyTests: XCTestCase {
|
|||||||
let string = String.Test.string
|
let string = String.Test.string
|
||||||
|
|
||||||
// WHEN
|
// WHEN
|
||||||
let result = string.isNotEmpty()
|
let result = string.isNotEmpty
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
XCTAssertTrue(result)
|
XCTAssertTrue(result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user