VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/python/tests/compareNodes.py@ 105420

Last change on this file since 105420 was 105420, checked in by vboxsync, 7 months ago

libxml2-2.12.6: Applied and adjusted our libxml2 changes to 2.12.6. bugref:10730

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/usr/bin/env python3
2import sys
3import setup_test
4import libxml2
5
6# Memory debug specific
7libxml2.debugMemory(1)
8
9#
10# Testing XML Node comparison and Node hash-value
11#
12doc = libxml2.parseDoc("""<root><foo/></root>""")
13root = doc.getRootElement()
14
15# Create two different objects which point to foo
16foonode1 = root.children
17foonode2 = root.children
18
19# Now check that [in]equality tests work ok
20if not ( foonode1 == foonode2 ):
21 print("Error comparing nodes with ==, nodes should be equal but are unequal")
22 sys.exit(1)
23if not ( foonode1 != root ):
24 print("Error comparing nodes with ==, nodes should not be equal but are equal")
25 sys.exit(1)
26if not ( foonode1 != root ):
27 print("Error comparing nodes with !=, nodes should not be equal but are equal")
28if ( foonode1 != foonode2 ):
29 print("Error comparing nodes with !=, nodes should be equal but are unequal")
30
31# Next check that the hash function for the objects also works ok
32if not (hash(foonode1) == hash(foonode2)):
33 print("Error hash values for two equal nodes are different")
34 sys.exit(1)
35if not (hash(foonode1) != hash(root)):
36 print("Error hash values for two unequal nodes are not different")
37 sys.exit(1)
38if hash(foonode1) == hash(root):
39 print("Error hash values for two unequal nodes are equal")
40 sys.exit(1)
41
42# Basic tests successful
43doc.freeDoc()
44
45# Memory debug specific
46libxml2.cleanupParser()
47if libxml2.debugMemory(1) == 0:
48 print("OK")
49else:
50 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette