Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/CFXMLNode.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ CFXMLNodeEqual (CFTypeRef cf1, CFTypeRef cf2)
}
}
default:
break;
return true;
}
}

return false;
}

Expand Down Expand Up @@ -446,7 +446,7 @@ CFXMLNodeGetString (CFXMLNodeRef node)
CFXMLNodeTypeCode
CFXMLNodeGetTypeCode (CFXMLNodeRef node)
{
return ((CFRuntimeBase*)node)->_flags.info;
return node->_type;
}

CFIndex
Expand Down
Empty file added Tests/CFXMLNode/TestInfo
Empty file.
35 changes: 35 additions & 0 deletions Tests/CFXMLNode/equal.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <CoreFoundation/CFXMLNode.h>
#include <CoreFoundation/CFString.h>

#include "../CFTesting.h"

int main (void)
{
CFXMLNodeRef t1;
CFXMLNodeRef t2;
CFXMLNodeRef t3;
CFXMLNodeRef c1;
CFXMLNodeRef c2;

t1 = CFXMLNodeCreate (NULL, kCFXMLNodeTypeText, CFSTR ("hello"), NULL, 1);
t2 = CFXMLNodeCreateCopy (NULL, t1);
PASS_CF(CFEqual (t1, t2), "Two identical text nodes are equal.");

t3 = CFXMLNodeCreate (NULL, kCFXMLNodeTypeText, CFSTR ("world"), NULL, 1);
PASS_CF(!CFEqual (t1, t3), "Text nodes with different strings are not equal.");

c1 = CFXMLNodeCreate (NULL, kCFXMLNodeTypeComment, CFSTR ("note"), NULL, 1);
c2 = CFXMLNodeCreateCopy (NULL, c1);
PASS_CF(CFEqual (c1, c2), "Two identical comment nodes are equal.");

PASS_CF(!CFEqual (t1, c1),
"A text node and a comment node are not equal.");

CFRelease (t1);
CFRelease (t2);
CFRelease (t3);
CFRelease (c1);
CFRelease (c2);

return 0;
}
58 changes: 58 additions & 0 deletions Tests/CFXMLNode/typecode.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <CoreFoundation/CFXMLNode.h>
#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFDictionary.h>
#include <CoreFoundation/CFArray.h>

#include "../CFTesting.h"

int main (void)
{
CFXMLNodeRef text;
CFXMLNodeRef comment;
CFXMLNodeRef elem;
CFXMLNodeRef pi;
CFXMLNodeRef copy;
CFDictionaryRef attrs;
CFArrayRef order;
CFXMLElementInfo einfo;
CFXMLProcessingInstructionInfo piinfo;

text = CFXMLNodeCreate (NULL, kCFXMLNodeTypeText, CFSTR ("t"), NULL, 1);
PASS_CF(CFXMLNodeGetTypeCode (text) == kCFXMLNodeTypeText,
"A text node reports the text type code.");

comment = CFXMLNodeCreate (NULL, kCFXMLNodeTypeComment, CFSTR ("c"), NULL, 1);
PASS_CF(CFXMLNodeGetTypeCode (comment) == kCFXMLNodeTypeComment,
"A comment node reports the comment type code.");

attrs = CFDictionaryCreate (NULL, NULL, NULL, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
order = CFArrayCreate (NULL, NULL, 0, &kCFTypeArrayCallBacks);
einfo.attributes = attrs;
einfo.attributeOrder = order;
einfo.isEmpty = true;
elem = CFXMLNodeCreate (NULL, kCFXMLNodeTypeElement, CFSTR ("e"), &einfo, 1);
PASS_CF(CFXMLNodeGetTypeCode (elem) == kCFXMLNodeTypeElement,
"An element node reports the element type code.");

piinfo.dataString = CFSTR ("d");
pi = CFXMLNodeCreate (NULL, kCFXMLNodeTypeProcessingInstruction,
CFSTR ("p"), &piinfo, 1);
PASS_CF(CFXMLNodeGetTypeCode (pi) == kCFXMLNodeTypeProcessingInstruction,
"A processing instruction reports the processing instruction type code.");

copy = CFXMLNodeCreateCopy (NULL, text);
PASS_CF(CFXMLNodeGetTypeCode (copy) == kCFXMLNodeTypeText,
"A copied node preserves its type code.");

CFRelease (text);
CFRelease (comment);
CFRelease (elem);
CFRelease (attrs);
CFRelease (order);
CFRelease (pi);
CFRelease (copy);

return 0;
}
Loading