Skip to content

Commit

Permalink
Fixed string.trim()
Browse files Browse the repository at this point in the history
  • Loading branch information
Esqarrouth committed Jun 4, 2016
1 parent 5805497 commit 609fce3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,11 +1,11 @@
language: objective-c
language: swift

branches:
only:
- master

xcode_project: EZSwiftExtensions.xcodeproj
xcode_scheme: EZSwiftExtensionsTests
xcode_scheme: EZSwiftExtensions
osx_image: xcode7.3
xcode_sdk: iphonesimulator9.1

Expand Down
8 changes: 6 additions & 2 deletions EZSwiftExtensionsTests/EZSwiftExtensionsTestsString.swift
Expand Up @@ -36,9 +36,13 @@ class EZSwiftExtensionsTestsString: XCTestCase {
}

func testTrim() {
string = "space space"
string = " Hello how are you "
string.trim()
XCTAssertFalse(string.containsString(" "))
XCTAssertEqual(string, "Hello how are you")

string = " \t\t Lets trim all the whitespace \n \t \n "
string.trim()
XCTAssertEqual(string, "Lets trim all the whitespace")
}

func testIsEmail() {
Expand Down
2 changes: 1 addition & 1 deletion Sources/StringExtensions.swift
Expand Up @@ -53,7 +53,7 @@ extension String {

/// EZSE: Trims white space and new line characters, returns a new string
public func trimmed() -> String {
return self.componentsSeparatedByCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).joinWithSeparator("")
return self.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
}

/// EZSE: Checks if String contains Email
Expand Down

0 comments on commit 609fce3

Please sign in to comment.