mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 17:10:48 +00:00
add some set tests
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36374 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fda24afa52
commit
b2c85a7b0a
1 changed files with 55 additions and 0 deletions
55
Tests/base/NSMutableSet/general.m
Normal file
55
Tests/base/NSMutableSet/general.m
Normal file
|
@ -0,0 +1,55 @@
|
|||
#import <Foundation/NSSet.h>
|
||||
#import "ObjectTesting.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
START_SET("mutable set general")
|
||||
|
||||
id val1, val2, val3, val4, obj;
|
||||
NSMutableSet *vals1, *vals2, *vals3, *vals4;
|
||||
|
||||
val1 = @"Hello";
|
||||
val2 = @"A Goodbye";
|
||||
val3 = @"Testing all strings";
|
||||
val4 = @"Another";
|
||||
|
||||
vals1 = [NSMutableSet setWithObject: val1];
|
||||
vals2 = [vals1 setByAddingObject: val2];
|
||||
vals3 = [vals1 setByAddingObject: val3];
|
||||
vals4 = [NSMutableSet setWithObject: val4];
|
||||
|
||||
obj = [NSMutableSet set];
|
||||
PASS([obj isKindOfClass: [NSMutableSet class]] && [obj count] == 0,
|
||||
"-count returns zero for an empty set");
|
||||
PASS([obj hash] == 0, "-hash returns zero for an empty set");
|
||||
PASS(YES == [vals2 containsObject: val2], "-containsObject: works");
|
||||
PASS(nil != [vals2 member: @"A Goodbye"], "-member: finds present object");
|
||||
PASS(nil == [vals2 member: @"not there"], "-member: doesn't find missing");
|
||||
[obj unionSet: vals1];
|
||||
PASS_EQUAL(obj, vals1, "union of empty set with non-empty equals non-empty");
|
||||
PASS(1 == [obj count], "union contains one object");
|
||||
[obj unionSet: vals2];
|
||||
PASS(2 == [obj count], "union adds another object to set");
|
||||
|
||||
PASS(NO == [obj intersectsSet: [NSSet set]], "no intersection with empty");
|
||||
PASS(YES == [obj intersectsSet: vals3], "test for intersection");
|
||||
PASS(NO == [obj intersectsSet: vals4], "test for non-intersection");
|
||||
|
||||
PASS(NO == [obj isSubsetOfSet: [NSSet set]], "not subset of empty");
|
||||
PASS(NO == [obj isSubsetOfSet: vals1], "test non subset");
|
||||
PASS(YES == [vals1 isSubsetOfSet: obj], "test subset");
|
||||
|
||||
[obj intersectSet: vals3];
|
||||
PASS_EQUAL([obj anyObject], val1, "intersection removes an object");
|
||||
|
||||
[obj intersectSet: [NSSet set]];
|
||||
PASS(0 == [obj count], "intersect with empty set empties receiver");
|
||||
|
||||
[obj addObject: val1];
|
||||
[obj intersectSet: nil];
|
||||
PASS(0 == [obj count], "intersect with nil empties receiver");
|
||||
|
||||
END_SET("mutable set general")
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue