-
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 #724 from briandowns/featuer/string_functions
Added IsLower and isUpper and wordCount string methods
- Loading branch information
Showing
6 changed files
with
170 additions
and
1 deletion.
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,21 @@ | ||
/** | ||
* isLower.du | ||
* | ||
* Testing the str.isLower() method | ||
* | ||
* .isLower() returns a boolean indicating that the given string is | ||
* an lower case letter. | ||
*/ | ||
from UnitTest import UnitTest; | ||
|
||
class TestStringIsLower < UnitTest { | ||
testStringIsLower() { | ||
this.assertTruthy("d".isLower()); | ||
this.assertTruthy("dog".isLower()); | ||
this.assertTruthy("g00d!".isLower()); | ||
this.assertFalsey("D".isLower()); | ||
this.assertFalsey("Maple".isLower()); | ||
} | ||
} | ||
|
||
TestStringIsLower().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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* isUpper.du | ||
* | ||
* Testing the str.isUpper() method | ||
* | ||
* .isUpper() returns a boolean indicating that the given string is | ||
* an upper case letter. | ||
*/ | ||
from UnitTest import UnitTest; | ||
|
||
class TestStringIsUpper < UnitTest { | ||
testStringIsUpper() { | ||
this.assertTruthy("D".isUpper()); | ||
this.assertTruthy("DOG".isUpper()); | ||
this.assertTruthy("G00D!".isUpper()); | ||
this.assertFalsey("Maple".isUpper()); | ||
} | ||
} | ||
|
||
TestStringIsUpper().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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* wordCount.du | ||
* | ||
* Testing the str.wordCount() method | ||
* | ||
* .wordCount() returns the number of words in the given string. | ||
*/ | ||
from UnitTest import UnitTest; | ||
|
||
class TestStringWordCount < UnitTest { | ||
testStringWordCount() { | ||
this.assertEquals("".wordCount(), 0); | ||
this.assertEquals("This".wordCount(), 1); | ||
this.assertEquals("This is a sentence".wordCount(), 4); | ||
this.assertEquals("This is an even longer sentence".wordCount(), 6); | ||
} | ||
} | ||
|
||
TestStringWordCount().run(); |