mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Add macos archive test
This commit is contained in:
parent
353aa6c8e5
commit
f2ba8a3093
3 changed files with 136 additions and 44 deletions
|
@ -40,8 +40,8 @@
|
|||
#import "GSSorting.h"
|
||||
|
||||
#define GSI_ARRAY_TYPE NSRange
|
||||
#define GSI_ARRAY_NO_RELEASE 1
|
||||
#define GSI_ARRAY_NO_RETAIN 1
|
||||
#define GSI_ARRAY_NO_RELEASE 0
|
||||
#define GSI_ARRAY_NO_RETAIN 0
|
||||
#define GSI_ARRAY_TYPES GSUNION_OBJ
|
||||
|
||||
#define GSI_ARRAY_RELEASE(A, X) [(X).obj release]
|
||||
|
@ -176,17 +176,6 @@ static Class mutableSetClass;
|
|||
return AUTORELEASE([[GSOrderedSetEnumeratorReverse alloc] initWithOrderedSet: self]);
|
||||
}
|
||||
|
||||
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
|
||||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
//state->mutationsPtr = (unsigned long *)self;
|
||||
//return GSIMapCountByEnumeratingWithStateObjectsCount
|
||||
// (&map, state, stackbuf, len);
|
||||
|
||||
return [self count];
|
||||
}
|
||||
|
||||
- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude
|
||||
{
|
||||
NSUInteger size = GSPrivateMemorySize(self, exclude);
|
||||
|
@ -296,16 +285,6 @@ static Class mutableSetClass;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) _insertObject: (id)object atIndex: (NSUInteger)index
|
||||
{
|
||||
GSIArrayItem item;
|
||||
|
||||
item.obj = object;
|
||||
GSIArrayInsertItem(&array, item, index);
|
||||
RETAIN(object);
|
||||
_version++;
|
||||
}
|
||||
|
||||
- (void) removeObjectAtIndex: (NSUInteger)index
|
||||
{
|
||||
_version++;
|
||||
|
@ -316,7 +295,7 @@ static Class mutableSetClass;
|
|||
withObject: (id)obj
|
||||
{
|
||||
[self removeObjectAtIndex: index];
|
||||
[self _insertObject: obj atIndex: index];
|
||||
[self insertObject: obj atIndex: index];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
|
@ -375,14 +354,5 @@ static Class mutableSetClass;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
|
||||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
//state->mutationsPtr = (unsigned long *)&_version;
|
||||
//return GSIMapCountByEnumeratingWithStateObjectsCount
|
||||
// (&map, state, stackbuf, len);
|
||||
return [self count];
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -53,10 +53,6 @@
|
|||
- (void) _raiseRangeExceptionWithIndex: (NSUInteger)index from: (SEL)sel;
|
||||
@end
|
||||
|
||||
@interface NSMutableOrderedSet (Private)
|
||||
- (void) _insertObject: (id)object atIndex: (NSUInteger)index;
|
||||
@end
|
||||
|
||||
@implementation NSOrderedSet
|
||||
|
||||
static Class NSOrderedSet_abstract_class;
|
||||
|
@ -1158,19 +1154,25 @@ static SEL rlSel;
|
|||
|
||||
// -1. If this set is empty, this method should return YES.
|
||||
if (l == 0)
|
||||
return YES;
|
||||
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
// If count of set is more than otherSet it's not a subset
|
||||
if (l > [otherSet count])
|
||||
return NO;
|
||||
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Find the first object's index in otherset, if not found
|
||||
// it's not a subset...
|
||||
f = [self firstObject];
|
||||
s = [otherSet indexOfObject: f];
|
||||
if(s == NSNotFound)
|
||||
return NO;
|
||||
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
for(i = 0; i < l; i++)
|
||||
{
|
||||
NSUInteger j = s + i;
|
||||
|
@ -1689,7 +1691,7 @@ static SEL rlSel;
|
|||
e = [tmpArray objectEnumerator];
|
||||
while((o = [e nextObject]) != nil)
|
||||
{
|
||||
[self _insertObject: o atIndex: index];
|
||||
[self insertObject: o atIndex: index];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,118 @@
|
|||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSOrderedSet.h>
|
||||
|
||||
static NSString *stringData = @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
@"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"
|
||||
@"<plist version=\"1.0\">"
|
||||
@"<dict>"
|
||||
@" <key>$archiver</key>"
|
||||
@" <string>NSKeyedArchiver</string>"
|
||||
@" <key>$objects</key>"
|
||||
@" <array>"
|
||||
@" <string>$null</string>"
|
||||
@" <dict>"
|
||||
@" <key>$class</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>14</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.0</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>2</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.1</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>3</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.10</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>12</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.11</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>13</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.2</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>4</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.3</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>5</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.4</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>6</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.5</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>7</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.6</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>8</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.7</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>9</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.8</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>10</integer>"
|
||||
@" </dict>"
|
||||
@" <key>NS.object.9</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>11</integer>"
|
||||
@" </dict>"
|
||||
@" </dict>"
|
||||
@" <string>Now</string>"
|
||||
@" <string>is</string>"
|
||||
@" <string>the</string>"
|
||||
@" <string>time</string>"
|
||||
@" <string>for</string>"
|
||||
@" <string>all</string>"
|
||||
@" <string>Horrible</string>"
|
||||
@" <string>men</string>"
|
||||
@" <string>to</string>"
|
||||
@" <string>Flee From</string>"
|
||||
@" <string>the aid</string>"
|
||||
@" <string>of their country</string>"
|
||||
@" <dict>"
|
||||
@" <key>$classes</key>"
|
||||
@" <array>"
|
||||
@" <string>NSMutableOrderedSet</string>"
|
||||
@" <string>NSOrderedSet</string>"
|
||||
@" <string>NSObject</string>"
|
||||
@" </array>"
|
||||
@" <key>$classname</key>"
|
||||
@" <string>NSMutableOrderedSet</string>"
|
||||
@" </dict>"
|
||||
@" </array>"
|
||||
@" <key>$top</key>"
|
||||
@" <dict>"
|
||||
@" <key>root</key>"
|
||||
@" <dict>"
|
||||
@" <key>CF$UID</key>"
|
||||
@" <integer>1</integer>"
|
||||
@" </dict>"
|
||||
@" </dict>"
|
||||
@" <key>$version</key>"
|
||||
@" <integer>100000</integer>"
|
||||
@"</dict>"
|
||||
@"</plist>";
|
||||
|
||||
int main()
|
||||
{
|
||||
START_SET("NSOrderedSet base")
|
||||
|
@ -9,6 +121,7 @@ int main()
|
|||
NSOrderedSet *testObj, *testObj2;
|
||||
NSMutableOrderedSet *mutableTest1, *mutableTest2;
|
||||
NSMutableArray *testObjs = [NSMutableArray new];
|
||||
NSData *data = [stringData dataUsingEncoding: NSUTF8StringEncoding];
|
||||
|
||||
testObj = [NSOrderedSet new];
|
||||
[testObjs addObject: testObj];
|
||||
|
@ -224,6 +337,13 @@ int main()
|
|||
[testObjs addObject: mutableTest4];
|
||||
PASS([[mutableTest4 objectAtIndex: 9] isEqual:@"Flee From"] == YES,
|
||||
"replaceObjectsAtIndexes: adds to correct indexes");
|
||||
|
||||
|
||||
id uobj = [NSKeyedUnarchiver unarchiveObjectWithData: data];
|
||||
PASS((uobj != nil &&
|
||||
[uobj isKindOfClass: [NSMutableOrderedSet class]] &&
|
||||
[uobj containsObject: @"Now"]),
|
||||
"Object unarchives correctly from macOS archive")
|
||||
|
||||
test_NSObject(@"NSOrderedSet", testObjs);
|
||||
test_NSCoding(testObjs);
|
||||
|
|
Loading…
Reference in a new issue