- moved componentsSeparatedByCharactersInSet: into CPCharacterSetAdditions CPString category

- added tests for componentsSeparatedByCharactersInSet:
- ensured Cocoa compatibility of componentsSeparatedByCharactersInSet:
- added new test for CPString boolValue
- fixed CPString boolValue (" ++01" should return NO as in Cocoa, previously it returned YES)
This commit is contained in:
Arkadiusz Młynarczyk
2010-09-10 18:58:18 -04:00
committed by Alexander Ljungberg
parent 009683ddd4
commit ddfac8d717
3 changed files with 78 additions and 47 deletions
+40 -1
View File
@@ -1,4 +1,5 @@
@import <Foundation/CPString.j>
@import <Foundation/CPCharacterSet.j>
@implementation CPStringTest : OJTestCase
@@ -144,7 +145,8 @@
[" NO", NO],
[" -N00", NO],
[" 00", NO],
[" -00", NO]
[" -00", NO],
[" -+001", NO],
];
for (var i = 0; i < testStrings.length; i++)
@@ -312,4 +314,41 @@
[self assertFalse:["abc" hasSuffix:""]];
}
- (void)testComponentsSeparatedByCharactersInSetEmptyString
{
[self assert:[""]
equals:["" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
}
- (void)testComponentsSeparatedByCharactersInSetStringWithoutCharactersFromSet
{
[self assert:["Abradab"]
equals:["Abradab" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
}
- (void)testComponentsSeparatedByCharactersInSet
{
[self assert:["Baku", "baku", "to", "jest", "", "skład."]
equals:["Baku baku to jest skład." componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
}
- (void)testComponentsSeparatedByCharactersInSetLeadingAndTrailingCharacterFromSet
{
[self assert:["", "Test", ""]
equals:[" Test " componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
}
- (void)testComponentsSeparatedByCharactersExceptionRaiseOnNilSeparator
{
try
{
[[CPString string] componentsSeparatedByCharactersInSet:nil];
[self assert:false];
}
catch (anException)
{
[self assert:[anException name] equals:CPInvalidArgumentException];
[self assert:[anException reason] equals:@"componentsSeparatedByCharactersInSet: the separator can't be 'nil'"];
}
}
@end