aboutsummaryrefslogtreecommitdiffstats
path: root/UnitTests
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-01-27 12:02:48 +0100
committerMax <post@wickenrode.com>2015-01-27 12:02:48 +0100
commitaa15d317223cc0d1f0d3267728132b7bdbf238df (patch)
treeed2b1a9bc123eec1f295171928e9d1173fffb212 /UnitTests
parentc9c96aff2a9e7201859f9ac6c46c0d9986f22ac3 (diff)
downloadsequelpro-aa15d317223cc0d1f0d3267728132b7bdbf238df.tar.gz
sequelpro-aa15d317223cc0d1f0d3267728132b7bdbf238df.tar.bz2
sequelpro-aa15d317223cc0d1f0d3267728132b7bdbf238df.zip
Expand previous unit test
Diffstat (limited to 'UnitTests')
-rw-r--r--UnitTests/SPParserUtilsTest.m12
1 files changed, 12 insertions, 0 deletions
diff --git a/UnitTests/SPParserUtilsTest.m b/UnitTests/SPParserUtilsTest.m
index c760e8b5..5066f8f7 100644
--- a/UnitTests/SPParserUtilsTest.m
+++ b/UnitTests/SPParserUtilsTest.m
@@ -48,6 +48,13 @@
NSString *emptyString = [NSString stringWithCString:empty encoding:NSUTF8StringEncoding];
STAssertEquals(utf8strlen(empty),[emptyString length], @"empty string");
+ // This is just a little safeguard.
+ // If any of those conditions fail, all of the following assumptions are moot.
+ const char *charSeq = "\xF0\x9F\x8D\x8F"; //🍏
+ NSString *charString = [NSString stringWithCString:charSeq encoding:NSUTF8StringEncoding];
+ STAssertEquals(strlen(charSeq), 4, @"assumption about storage for binary C string");
+ STAssertEquals([charString length], 2, @"assumption about NSString internal storage of string");
+
const char *singleByteSeq = "Hello World!";
NSString *singleByteString = [NSString stringWithCString:singleByteSeq encoding:NSUTF8StringEncoding];
STAssertEquals(utf8strlen(singleByteSeq), [singleByteString length], @"ASCII UTF-8 subset");
@@ -67,6 +74,11 @@
const char *mixedSeq = "\xE3\x81\x82\xE3\x82\x81\xE3\x80\x90\xE9\xA3\xB4\xE3\x80\x91\xF0\x9F\x8D\xAD \xE2\x89\x88 S\xC3\xBC\xC3\x9Figkeit"; // あめ【飴】🍭 ≈ Süßigkeit
NSString *mixedString = [NSString stringWithCString:mixedSeq encoding:NSUTF8StringEncoding];
STAssertEquals(utf8strlen(mixedSeq), [mixedString length], @"utf8 characters with all 4 lengths mixed together.");
+
+ //composed vs. decomposed chars
+ const char *decompSeq = "\xC3\xA4 - a\xCC\x88"; // ä - ä
+ NSString *decompString = [NSString stringWithCString:decompSeq encoding:NSUTF8StringEncoding];
+ STAssertEquals(utf8strlen(decompSeq), [decompString length], @"\"LATIN SMALL LETTER A WITH DIAERESIS\" vs. \"LATIN SMALL LETTER A\" + \"COMBINING DIAERESIS\"");
}
@end