add basic equality tests

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34436 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2012-01-06 09:24:51 +00:00
parent e9380ba351
commit 8042dedeeb
3 changed files with 45 additions and 2 deletions

View file

View file

@ -0,0 +1,29 @@
#import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSXMLElement.h>
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSXMLElement *node;
NSXMLElement *other;
node = [[NSXMLElement alloc] initWithName: @"node"];
test_alloc(@"NSXMLElement");
test_NSObject(@"NSXMLElement", [NSArray arrayWithObject: node]);
other = [[NSXMLElement alloc] initWithName: @"other"];
PASS(NO == [other isEqual: node], "differently named elements are not equal");
[other setName: @"node"];
PASS_EQUAL([other name], @"node", "setting name of element works");
PASS([other isEqual: node], "elements with same name are equal");
[other release];
[node release];
[arp release];
arp = nil;
return 0;
}

View file

@ -1,17 +1,31 @@
#import "ObjectTesting.h" #import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h> #import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSXMLNode.h> #import <Foundation/NSXMLNode.h>
int main() int main()
{ {
NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSXMLNode *node; NSXMLNode *node;
NSXMLNode *other;
node = [[NSXMLNode alloc] initWithKind: NSXMLInvalidKind]; node = [[NSXMLNode alloc] initWithKind: NSXMLInvalidKind];
test_alloc(@"NSXMLNode"); test_alloc(@"NSXMLNode");
test_NSObject(@"NSXMLNode", [NSArray arrayWithObject: node]); test_NSObject(@"NSXMLNode", [NSArray arrayWithObject: node]);
other = [[NSXMLNode alloc] initWithKind: NSXMLElementKind];
PASS(NO == [other isEqual: node], "different node kinds are not equal");
[other release];
other = [[NSXMLNode alloc] initWithKind: NSXMLInvalidKind];
PASS([other isEqual: node], "empty nodes are equal");
[node release];
[other setName: @"other"];
PASS(nil == [other name], "setting name on invalid node gives a nil name");
[other release];
[arp release]; [arp release];
arp = nil; arp = nil;
[node release];
return 0; return 0;
} }