aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-11-13 17:34:23 +0100
committerMax <post@wickenrode.com>2015-11-13 17:34:23 +0100
commit017ad9b38b87af09134c015086b47799acbcee0b (patch)
treeb32182acde2f9639670a0337da46e1ab5aa4d1e0 /UnitTests
parent0dbadf887635bb3904d3aa64a0588a0b23d884dc (diff)
downloadsequelpro-017ad9b38b87af09134c015086b47799acbcee0b.tar.gz
sequelpro-017ad9b38b87af09134c015086b47799acbcee0b.tar.bz2
sequelpro-017ad9b38b87af09134c015086b47799acbcee0b.zip
Fix: "Custom filename" in export dialog would accept multi line text (#2325)
Diffstat (limited to 'UnitTests')
-rw-r--r--UnitTests/SPStringAdditionsTests.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/UnitTests/SPStringAdditionsTests.m b/UnitTests/SPStringAdditionsTests.m
index 23ec82e9..00cbdc14 100644
--- a/UnitTests/SPStringAdditionsTests.m
+++ b/UnitTests/SPStringAdditionsTests.m
@@ -39,6 +39,7 @@
- (void)testStringWithNewUUID;
- (void)testCreateViewSyntaxPrettifier;
- (void)testNonConsecutivelySearchStringMatchingRanges;
+- (void)testStringByReplacingCharactersInSetWithString;
@end
@@ -195,6 +196,26 @@ static NSRange RangeFromArray(NSArray *a,NSUInteger idx);
}
+- (void)testStringByReplacingCharactersInSetWithString
+{
+ {
+ //test against empty string
+ STAssertEqualObjects([@"" stringByReplacingCharactersInSet:[NSCharacterSet whitespaceCharacterSet] withString:@"x"], @"", @"replacement on empty string must result in empty string");
+ }
+ {
+ //test match at begin, middle, end / consecutive matches
+ STAssertEqualObjects([@" ab c " stringByReplacingCharactersInSet:[NSCharacterSet whitespaceCharacterSet] withString:@"_"], @"_ab__c_", @"Testing matches at both end, replacement of consecutive matches");
+ }
+ {
+ //test replacement of different characters
+ STAssertEqualObjects([@"ab\r\ncd" stringByReplacingCharactersInSet:[NSCharacterSet newlineCharacterSet] withString:@"*"], @"ab**cd", @"Testing replacement of different characters in set");
+ }
+ {
+ // nil for replacement char
+ STAssertEqualObjects([@"ab\r\ncd" stringByReplacingCharactersInSet:[NSCharacterSet newlineCharacterSet] withString:nil], @"abcd", @"testing replacement with nil");
+ }
+}
+
@end
NSRange RangeFromArray(NSArray *a,NSUInteger idx)