-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #725 from briandowns/feature/more_string_methods
Feature/more string methods
- Loading branch information
Showing
7 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* collapseSpaces.du | ||
* | ||
* Testing the str.collapseSpaces() method | ||
* | ||
* .collapseSpaces() returns a string with extraneous spaces removed. | ||
*/ | ||
from UnitTest import UnitTest; | ||
|
||
class TestStringCollapseSpaces < UnitTest { | ||
testStringCollapseSpaces() { | ||
const testString = "This is a huge string of a lot of spaces."; | ||
const expected = "This is a huge string of a lot of spaces."; | ||
const res = testString.collapseSpaces(); | ||
this.assertEquals(res, expected); | ||
this.assertNotEquals(testString, expected); | ||
} | ||
} | ||
|
||
TestStringCollapseSpaces().run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ class TestStringConcat < UnitTest { | |
} | ||
} | ||
|
||
TestStringConcat().run(); | ||
TestStringConcat().run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* wrap.du | ||
* | ||
* Testing the str.wrap() method | ||
* | ||
* .wrap() returns a new string with new lines inserted at the given length. | ||
*/ | ||
from UnitTest import UnitTest; | ||
|
||
class TestStringWrap < UnitTest { | ||
const maxLen = 80; | ||
|
||
testStringWrap() { | ||
const testString = "This is a really really long string that will need to be broken up for whatever reason the caller has determined. Not out business as to why, but we can provide the functionality for them to do so."; | ||
const res = testString.wrap(this.maxLen); | ||
const idx = res.find("\n"); | ||
this.assertTruthy(res.find("\n") <= this.maxLen); | ||
} | ||
} | ||
|
||
TestStringWrap().run(); |