2012-02-08 17:42:24 +00:00
|
|
|
#import "ObjectTesting.h"
|
|
|
|
#import <Foundation/NSAutoreleasePool.h>
|
|
|
|
#import <Foundation/NSOrderedSet.h>
|
|
|
|
|
2019-06-18 00:00:50 +00:00
|
|
|
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>";
|
|
|
|
|
2012-02-08 17:42:24 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
START_SET("NSOrderedSet base")
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-10 14:20:26 +00:00
|
|
|
NSOrderedSet *testObj, *testObj2;
|
2019-06-09 11:17:57 +00:00
|
|
|
NSMutableOrderedSet *mutableTest1, *mutableTest2;
|
2024-11-16 14:07:33 +00:00
|
|
|
NSMutableArray *testObjs = [NSMutableArray array];
|
2019-06-18 00:00:50 +00:00
|
|
|
NSData *data = [stringData dataUsingEncoding: NSUTF8StringEncoding];
|
2019-06-27 13:26:01 +00:00
|
|
|
NSMutableSet *testSet;
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2025-01-09 10:03:32 +00:00
|
|
|
testObj = AUTORELEASE([NSOrderedSet new]);
|
2012-02-08 17:42:24 +00:00
|
|
|
[testObjs addObject: testObj];
|
|
|
|
PASS(testObj != nil && [testObj count] == 0,
|
2019-06-09 11:17:57 +00:00
|
|
|
"can create an empty ordered set");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-08 12:56:18 +00:00
|
|
|
testObj = [NSOrderedSet orderedSetWithObject: @"Hello"];
|
2012-02-08 17:42:24 +00:00
|
|
|
[testObjs addObject: testObj];
|
|
|
|
PASS(testObj != nil && [testObj count] == 1,
|
2019-06-09 11:17:57 +00:00
|
|
|
"can create an ordered set with one element");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-09 11:17:57 +00:00
|
|
|
id objs[] = {@"Hello", @"Hello1"};
|
|
|
|
testObj = [NSOrderedSet orderedSetWithObjects: objs count: 2];
|
|
|
|
[testObjs addObject: testObj];
|
|
|
|
PASS(testObj != nil && [testObj count] == 2,
|
|
|
|
"can create an ordered set with multi element");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-09 11:17:57 +00:00
|
|
|
id objs1[] = {@"Hello", @"Hello"};
|
|
|
|
testObj = [NSOrderedSet orderedSetWithObjects: objs1 count: 2];
|
|
|
|
[testObjs addObject: testObj];
|
|
|
|
PASS(testObj != nil && [testObj count] == 1,
|
|
|
|
"cannot create an ordered set with multiple like elements");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-09 11:17:57 +00:00
|
|
|
NSMutableArray *arr = [NSMutableArray array];
|
|
|
|
[arr addObject: @"Hello"];
|
|
|
|
[arr addObject: @"World"];
|
|
|
|
testObj = [NSOrderedSet orderedSetWithArray: arr];
|
|
|
|
[testObjs addObject: testObj];
|
|
|
|
PASS(testObj != nil && [testObj count] == 2,
|
|
|
|
"Is able to initialize with array");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-09 11:17:57 +00:00
|
|
|
id objs3[] = {@"Hello"};
|
|
|
|
id objc4[] = {@"World"};
|
|
|
|
testObj = [NSOrderedSet orderedSetWithObjects: objs3 count: 1];
|
|
|
|
[testObjs addObject: testObj];
|
|
|
|
testObj2 = [NSOrderedSet orderedSetWithObjects: objc4 count: 1];
|
|
|
|
[testObjs addObject: testObj2];
|
|
|
|
BOOL result = [testObj intersectsOrderedSet: testObj2];
|
|
|
|
PASS(result == NO,
|
|
|
|
"Sets do not intersect!");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-09 11:17:57 +00:00
|
|
|
id objs5[] = {@"Hello"};
|
|
|
|
id objc6[] = {@"Hello"};
|
|
|
|
testObj = [NSOrderedSet orderedSetWithObjects: objs5 count: 1];
|
|
|
|
[testObjs addObject: testObj];
|
|
|
|
testObj2 = [NSOrderedSet orderedSetWithObjects: objc6 count: 1];
|
|
|
|
[testObjs addObject: testObj2];
|
|
|
|
BOOL result1 = [testObj intersectsOrderedSet: testObj2];
|
|
|
|
PASS(result1 == YES,
|
|
|
|
"Sets do intersect!");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-09 11:17:57 +00:00
|
|
|
id o1 = @"Hello";
|
|
|
|
id o2 = @"World";
|
|
|
|
mutableTest1 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 addObject: o1];
|
2019-06-09 11:17:57 +00:00
|
|
|
[testObjs addObject: mutableTest1];
|
|
|
|
mutableTest2 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest2 addObject: o2];
|
2019-06-09 11:17:57 +00:00
|
|
|
[testObjs addObject: mutableTest2];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 unionOrderedSet: mutableTest2];
|
2019-06-09 11:17:57 +00:00
|
|
|
PASS(mutableTest1 != nil && mutableTest2 != nil && [mutableTest1 count] == 2,
|
|
|
|
"mutableSets union properly");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-09 11:17:57 +00:00
|
|
|
id o3 = @"Hello";
|
|
|
|
id o4 = @"World";
|
|
|
|
mutableTest1 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 addObject: o3];
|
2019-06-09 11:17:57 +00:00
|
|
|
[testObjs addObject: mutableTest1];
|
|
|
|
mutableTest2 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest2 addObject: o4];
|
2019-06-09 11:17:57 +00:00
|
|
|
[testObjs addObject: mutableTest2];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 intersectOrderedSet: mutableTest2];
|
2019-06-09 11:17:57 +00:00
|
|
|
PASS(mutableTest1 != nil && mutableTest2 != nil && [mutableTest1 count] == 0,
|
|
|
|
"mutableSets do not intersect");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-09 11:17:57 +00:00
|
|
|
id o5 = @"Hello";
|
|
|
|
id o6 = @"Hello";
|
|
|
|
mutableTest1 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 addObject: o5];
|
2019-06-09 11:17:57 +00:00
|
|
|
[testObjs addObject: mutableTest1];
|
|
|
|
mutableTest2 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest2 addObject: o6];
|
2019-06-09 11:17:57 +00:00
|
|
|
[testObjs addObject: mutableTest2];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 intersectOrderedSet: mutableTest2];
|
2019-06-09 11:17:57 +00:00
|
|
|
PASS(mutableTest1 != nil && mutableTest2 != nil && [mutableTest1 count] == 1,
|
|
|
|
"mutableSets do intersect");
|
2019-06-09 18:53:06 +00:00
|
|
|
|
|
|
|
id o7 = @"Hello";
|
|
|
|
id o8 = @"World";
|
|
|
|
mutableTest1 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 addObject: o7];
|
|
|
|
[mutableTest1 addObject: o8];
|
2019-06-09 18:53:06 +00:00
|
|
|
[testObjs addObject: mutableTest1];
|
|
|
|
mutableTest2 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest2 addObject: o7];
|
2019-06-09 18:53:06 +00:00
|
|
|
[testObjs addObject: mutableTest2];
|
2019-06-27 13:10:14 +00:00
|
|
|
BOOL isSubset = [mutableTest2 isSubsetOfOrderedSet: mutableTest1];
|
2019-06-09 18:53:06 +00:00
|
|
|
PASS(isSubset,
|
|
|
|
"mutableTest2 is subset of mutableTest1");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-27 13:26:01 +00:00
|
|
|
testSet = [NSMutableSet set];
|
|
|
|
[testSet addObject: o7];
|
|
|
|
[testSet addObject: o8];
|
|
|
|
isSubset = [mutableTest2 isSubsetOfSet: testSet];
|
|
|
|
PASS(isSubset,
|
|
|
|
"mutableTest2 is subset of testSet");
|
|
|
|
|
2019-06-09 18:53:06 +00:00
|
|
|
id o9 = @"Hello";
|
|
|
|
id o10 = @"World";
|
|
|
|
id o11 = @"Ready";
|
|
|
|
mutableTest1 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 addObject: o9];
|
2019-06-09 18:53:06 +00:00
|
|
|
[testObjs addObject: mutableTest1];
|
|
|
|
mutableTest2 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest2 addObject: o10];
|
|
|
|
[mutableTest2 addObject: o9];
|
2019-06-09 18:53:06 +00:00
|
|
|
[testObjs addObject: mutableTest2];
|
2019-06-27 13:10:14 +00:00
|
|
|
isSubset = [mutableTest2 isSubsetOfOrderedSet: mutableTest1];
|
2019-06-09 18:53:06 +00:00
|
|
|
PASS(isSubset == NO,
|
|
|
|
"mutableTest2 is not subset of mutableTest1");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-27 13:26:01 +00:00
|
|
|
testSet = [NSMutableSet set];
|
|
|
|
[testSet addObject: o9];
|
|
|
|
isSubset = [mutableTest2 isSubsetOfSet: testSet];
|
|
|
|
PASS(isSubset == NO,
|
|
|
|
"mutableTest2 is not subset of testSet");
|
|
|
|
|
2019-06-09 18:53:06 +00:00
|
|
|
o9 = @"Hello";
|
|
|
|
o10 = @"World";
|
|
|
|
o11 = @"Ready";
|
|
|
|
id o12 = @"ToGo";
|
|
|
|
mutableTest1 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 addObject: o9];
|
|
|
|
[mutableTest1 addObject: o10];
|
|
|
|
[mutableTest1 addObject: o12];
|
|
|
|
[mutableTest1 addObject: o11];
|
2019-06-09 18:53:06 +00:00
|
|
|
[testObjs addObject: mutableTest1];
|
|
|
|
mutableTest2 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest2 addObject: o9];
|
|
|
|
[mutableTest2 addObject: o10];
|
2019-06-09 18:53:06 +00:00
|
|
|
[testObjs addObject: mutableTest2];
|
2019-06-27 13:10:14 +00:00
|
|
|
isSubset = [mutableTest2 isSubsetOfOrderedSet: mutableTest1];
|
2019-06-12 12:21:32 +00:00
|
|
|
PASS(isSubset,
|
|
|
|
"mutableTest2 is subset of mutableTest1");
|
2019-06-10 14:20:26 +00:00
|
|
|
|
2019-06-27 13:26:01 +00:00
|
|
|
testSet = [NSMutableSet set];
|
|
|
|
[testSet addObject: o9];
|
|
|
|
[testSet addObject: o10];
|
|
|
|
[testSet addObject: o12];
|
|
|
|
[testSet addObject: o11];
|
|
|
|
isSubset = [mutableTest2 isSubsetOfSet: testSet];
|
|
|
|
PASS(isSubset,
|
|
|
|
"mutableTest2 is subset of testSet");
|
|
|
|
|
2019-06-10 14:20:26 +00:00
|
|
|
o9 = @"Hello";
|
2019-06-12 12:21:32 +00:00
|
|
|
o10 = @"World";
|
2019-06-10 14:20:26 +00:00
|
|
|
o11 = @"Ready";
|
|
|
|
o12 = @"ToGo";
|
|
|
|
mutableTest1 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest1 addObject: o9];
|
|
|
|
[mutableTest1 addObject: o10];
|
|
|
|
[mutableTest1 addObject: o12];
|
|
|
|
[mutableTest1 addObject: o11];
|
2019-06-10 14:20:26 +00:00
|
|
|
[testObjs addObject: mutableTest1];
|
2019-06-27 13:10:14 +00:00
|
|
|
PASS([mutableTest1 isEqual: mutableTest1],
|
2019-06-10 14:20:26 +00:00
|
|
|
"mutableTest1 is equal to itself");
|
2019-06-12 12:21:32 +00:00
|
|
|
|
|
|
|
o9 = @"Hello";
|
|
|
|
o10 = @"World";
|
|
|
|
o11 = @"Ready";
|
|
|
|
o12 = @"ToGo";
|
|
|
|
NSMutableOrderedSet *mutableTest3 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest3 addObject: o9];
|
|
|
|
[mutableTest3 addObject: o10];
|
|
|
|
[mutableTest3 addObject: o12];
|
|
|
|
[mutableTest3 addObject: o11];
|
|
|
|
[mutableTest3 insertObject: @"Hello" atIndex: 2];
|
2019-06-12 12:21:32 +00:00
|
|
|
[testObjs addObject: mutableTest3];
|
2019-06-27 13:10:14 +00:00
|
|
|
PASS([mutableTest3 isEqual: mutableTest1] == YES,
|
2019-06-12 12:21:32 +00:00
|
|
|
"Insert at index does not replace existing object");
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2019-06-12 12:21:32 +00:00
|
|
|
NSMutableOrderedSet *mutableTest4 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest4 addObject: @"Now"];
|
|
|
|
[mutableTest4 addObject: @"is"];
|
|
|
|
[mutableTest4 addObject: @"the"];
|
|
|
|
[mutableTest4 addObject: @"time"];
|
|
|
|
[mutableTest4 addObject: @"for"];
|
|
|
|
[mutableTest4 addObject: @"all"];
|
|
|
|
[mutableTest4 addObject: @"Good"];
|
|
|
|
[mutableTest4 addObject: @"men"];
|
|
|
|
[mutableTest4 addObject: @"to"];
|
|
|
|
[mutableTest4 addObject: @"come"];
|
|
|
|
[mutableTest4 addObject: @"to the aid"];
|
|
|
|
[mutableTest4 addObject: @"of their country"];
|
|
|
|
[mutableTest4 moveObjectsAtIndexes: [NSIndexSet indexSetWithIndex: 3] toIndex: 10];
|
2019-06-12 12:21:32 +00:00
|
|
|
[testObjs addObject: mutableTest4];
|
2019-06-27 13:10:14 +00:00
|
|
|
PASS([[mutableTest4 objectAtIndex: 10] isEqual: @"time"] == YES,
|
2019-06-12 12:21:32 +00:00
|
|
|
"Move to index moves to correct index");
|
|
|
|
|
2019-06-12 15:23:33 +00:00
|
|
|
NSMutableOrderedSet *mutableTest5 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest5 addObject: @"Now"];
|
|
|
|
[mutableTest5 addObject: @"is"];
|
|
|
|
[mutableTest5 addObject: @"the"];
|
|
|
|
[mutableTest5 exchangeObjectAtIndex: 0 withObjectAtIndex: 2];
|
2019-06-12 15:23:33 +00:00
|
|
|
[testObjs addObject: mutableTest5];
|
2019-06-27 13:10:14 +00:00
|
|
|
PASS([[mutableTest5 objectAtIndex: 0] isEqual: @"the"] == YES &&
|
|
|
|
[[mutableTest5 objectAtIndex: 2] isEqual: @"Now"] == YES,
|
2019-06-12 15:23:33 +00:00
|
|
|
"Exchanges indexes properly");
|
|
|
|
//NSLog(@"RESULT: %@",mutableTest4);
|
2019-06-13 10:00:40 +00:00
|
|
|
|
|
|
|
mutableTest4 = [NSMutableOrderedSet orderedSet];
|
2019-06-27 13:10:14 +00:00
|
|
|
[mutableTest4 addObject: @"Now"];
|
|
|
|
[mutableTest4 addObject: @"is"];
|
|
|
|
[mutableTest4 addObject: @"the"];
|
|
|
|
[mutableTest4 addObject: @"time"];
|
|
|
|
[mutableTest4 addObject: @"for"];
|
|
|
|
[mutableTest4 addObject: @"all"];
|
|
|
|
[mutableTest4 addObject: @"Good"];
|
|
|
|
[mutableTest4 addObject: @"men"];
|
|
|
|
[mutableTest4 addObject: @"to"];
|
|
|
|
[mutableTest4 addObject: @"come to"];
|
|
|
|
[mutableTest4 addObject: @"the aid"];
|
|
|
|
[mutableTest4 addObject: @"of their country"];
|
|
|
|
NSMutableIndexSet *is = [NSMutableIndexSet indexSetWithIndex: 6];
|
2019-06-13 10:00:40 +00:00
|
|
|
[is addIndex: 9];
|
2019-06-27 13:10:14 +00:00
|
|
|
NSMutableArray *array = [NSMutableArray arrayWithObjects: @"Horrible", @"Flee From", nil];
|
2019-06-13 10:00:40 +00:00
|
|
|
[mutableTest4 replaceObjectsAtIndexes: is
|
|
|
|
withObjects: array];
|
|
|
|
[testObjs addObject: mutableTest4];
|
2019-06-27 13:10:14 +00:00
|
|
|
PASS([[mutableTest4 objectAtIndex: 9] isEqual: @"Flee From"] == YES,
|
2019-06-13 10:00:40 +00:00
|
|
|
"replaceObjectsAtIndexes: adds to correct indexes");
|
2019-06-18 00:00:50 +00:00
|
|
|
|
|
|
|
id uobj = [NSKeyedUnarchiver unarchiveObjectWithData: data];
|
|
|
|
PASS((uobj != nil &&
|
|
|
|
[uobj isKindOfClass: [NSMutableOrderedSet class]] &&
|
|
|
|
[uobj containsObject: @"Now"]),
|
|
|
|
"Object unarchives correctly from macOS archive")
|
2019-06-27 13:10:14 +00:00
|
|
|
|
2025-04-01 18:42:50 +00:00
|
|
|
[array removeAllObjects];
|
|
|
|
[array addObject: @"1"];
|
|
|
|
[array addObject: @"2"];
|
|
|
|
[array addObject: @"3"];
|
|
|
|
[array addObject: @"4"];
|
|
|
|
[array addObject: @"5"];
|
|
|
|
|
|
|
|
NSMutableOrderedSet *ms = [NSMutableOrderedSet orderedSetWithArray: array];
|
|
|
|
[ms removeObjectsAtIndexes:
|
|
|
|
[NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [array count])]];
|
|
|
|
|
2012-02-08 17:42:24 +00:00
|
|
|
test_NSObject(@"NSOrderedSet", testObjs);
|
|
|
|
test_NSCoding(testObjs);
|
|
|
|
test_NSCopying(@"NSOrderedSet", @"NSMutableOrderedSet", testObjs, YES, NO);
|
|
|
|
test_NSMutableCopying(@"NSOrderedSet", @"NSMutableOrderedSet", testObjs);
|
|
|
|
|
|
|
|
END_SET("NSOrderedSet base")
|
|
|
|
return 0;
|
|
|
|
}
|