mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fixed test
This commit is contained in:
parent
ae46b02ee2
commit
458958554b
2 changed files with 49 additions and 7 deletions
|
@ -1883,9 +1883,32 @@ compare(id elem1, id elem2, void* context)
|
|||
options: (NSEnumerationOptions)opts
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
{
|
||||
return [[self objectsAtIndexes: indexSet]
|
||||
indexesOfObjectsWithOptions: opts
|
||||
passingTest: predicate];
|
||||
NSIndexSet *rindexes =[[self objectsAtIndexes: indexSet]
|
||||
indexesOfObjectsWithOptions: opts
|
||||
passingTest: predicate];
|
||||
NSUInteger count = [indexSet count];
|
||||
NSUInteger resultCount = [rindexes count];
|
||||
NSUInteger indexArray[count], resultIndexArray[resultCount];
|
||||
NSMutableIndexSet *resultSet = [NSMutableIndexSet indexSet];
|
||||
NSUInteger i = 0;
|
||||
|
||||
[indexSet getIndexes: indexArray
|
||||
maxCount: count
|
||||
inIndexRange: NULL];
|
||||
|
||||
[rindexes getIndexes: resultIndexArray
|
||||
maxCount: resultCount
|
||||
inIndexRange: NULL];
|
||||
|
||||
// interate over indexes and collect the matching ones..
|
||||
for(i = 0; i < resultCount; i++)
|
||||
{
|
||||
NSUInteger rindx = resultIndexArray[i];
|
||||
NSUInteger indx = indexArray[rindx];
|
||||
[resultSet addIndex: indx];
|
||||
}
|
||||
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
- (NSUInteger) indexOfObjectWithOptions: (NSEnumerationOptions)opts
|
||||
|
@ -1958,9 +1981,17 @@ compare(id elem1, id elem2, void* context)
|
|||
options: (NSEnumerationOptions)opts
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
{
|
||||
return [[self objectsAtIndexes: indexSet]
|
||||
indexOfObjectWithOptions: 0
|
||||
passingTest: predicate];
|
||||
NSUInteger index = [[self objectsAtIndexes: indexSet]
|
||||
indexOfObjectWithOptions: 0
|
||||
passingTest: predicate];
|
||||
NSUInteger count = [indexSet count];
|
||||
NSUInteger indexArray[count];
|
||||
|
||||
[indexSet getIndexes: indexArray
|
||||
maxCount: count
|
||||
inIndexRange: NULL];
|
||||
|
||||
return indexArray[index];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -63,8 +63,19 @@ int main()
|
|||
passingTest:^BOOL(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
return [obj isEqualToString:@"Horrible"];
|
||||
}];
|
||||
PASS(index == 6, "indexOfObjectAtIndexes:... Returns correct index")
|
||||
PASS(index == 6, "indexOfObjectAtIndexes:... Returns correct index");
|
||||
|
||||
|
||||
NSMutableIndexSet *iset = [NSMutableIndexSet indexSetWithIndex: 6];
|
||||
[iset addIndex: 9];
|
||||
indexes = [mutableTest4 indexesOfObjectsAtIndexes: iset
|
||||
options:0
|
||||
passingTest:^BOOL(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
return [obj isEqualToString:@"Horrible"] || [obj isEqualToString:@"Flee From"];
|
||||
}];
|
||||
NSLog(@"indexes = %@",indexes);
|
||||
PASS([indexes containsIndex:6] && [indexes containsIndex:9], "indexesOfObjectsAtIndexes... returns correct indexes");
|
||||
|
||||
# else
|
||||
SKIP("No Blocks support in the compiler.")
|
||||
# endif
|
||||
|
|
Loading…
Reference in a new issue