VirtualBox

source: vbox/trunk/src/libs/libxml2-2.9.4/python/tests/compareNodes.py@ 71370

最後變更 在這個檔案從71370是 65950,由 vboxsync 提交於 8 年 前

libxml 2.9.4: fix export

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:executable 設為 *
檔案大小: 1.5 KB
 
1#!/usr/bin/python -u
2import sys
3import libxml2
4
5# Memory debug specific
6libxml2.debugMemory(1)
7
8#
9# Testing XML Node comparison and Node hash-value
10#
11doc = libxml2.parseDoc("""<root><foo/></root>""")
12root = doc.getRootElement()
13
14# Create two different objects which point to foo
15foonode1 = root.children
16foonode2 = root.children
17
18# Now check that [in]equality tests work ok
19if not ( foonode1 == foonode2 ):
20 print("Error comparing nodes with ==, nodes should be equal but are unequal")
21 sys.exit(1)
22if not ( foonode1 != root ):
23 print("Error comparing nodes with ==, nodes should not be equal but are equal")
24 sys.exit(1)
25if not ( foonode1 != root ):
26 print("Error comparing nodes with !=, nodes should not be equal but are equal")
27if ( foonode1 != foonode2 ):
28 print("Error comparing nodes with !=, nodes should be equal but are unequal")
29
30# Next check that the hash function for the objects also works ok
31if not (hash(foonode1) == hash(foonode2)):
32 print("Error hash values for two equal nodes are different")
33 sys.exit(1)
34if not (hash(foonode1) != hash(root)):
35 print("Error hash values for two unequal nodes are not different")
36 sys.exit(1)
37if hash(foonode1) == hash(root):
38 print("Error hash values for two unequal nodes are equal")
39 sys.exit(1)
40
41# Basic tests successful
42doc.freeDoc()
43
44# Memory debug specific
45libxml2.cleanupParser()
46if libxml2.debugMemory(1) == 0:
47 print("OK")
48else:
49 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
50 libxml2.dumpMemory()
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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