mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-15 11:13:50 +00:00
CPCharacterSet archiving support when the set is of the characterSetWithCharactersInString kind.
This commit is contained in:
1 parent
fcaf672bf8
commit
92c94eab8f
2 files changed
+38
No files matched your search
@@ -344,6 +344,27 @@ var _builtInCharacterSets = {};
|
||||
|
||||
@end
|
||||
|
||||
var _CPStringContentCharacterSetStringKey = @"_CPStringContentCharacterSetStringKey";
|
||||
|
||||
@implementation _CPStringContentCharacterSet (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
_string = [aCoder decodeObjectForKey:_CPStringContentCharacterSetStringKey]
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_string forKey:_CPStringContentCharacterSetStringKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
_CPCharacterSetTrimAtBeginning = 1 << 1;
|
||||
_CPCharacterSetTrimAtEnd = 1 << 2;
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
@import <Foundation/CPCharacterSet.j>
|
||||
|
||||
@implementation CPCharacterSetTest : OJTestCase
|
||||
|
||||
- (void)testArchiving
|
||||
{
|
||||
var charSet = [CPCharacterSet characterSetWithCharactersInString:"abc"],
|
||||
archived = [CPKeyedArchiver archivedDataWithRootObject:charSet],
|
||||
unarchived = [CPKeyedUnarchiver unarchiveObjectWithData:archived];
|
||||
|
||||
[self assertTrue:[unarchived characterIsMember:'a']];
|
||||
[self assertTrue:[unarchived characterIsMember:'b']];
|
||||
[self assertTrue:[unarchived characterIsMember:'c']];
|
||||
[self assertFalse:[unarchived characterIsMember:'d']];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user