VirtualBox

source: vbox/trunk/src/libs/libxml2-2.6.30/python/tests/readernext.py@ 7979

Last change on this file since 7979 was 6076, checked in by vboxsync, 17 years ago

Merged dmik/s2 branch (r25959:26751) to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 2.3 KB
Line 
1#!/usr/bin/python -u
2# -*- coding: ISO-8859-1 -*-
3#
4# this tests the next API of the XmlTextReader interface
5#
6import libxml2
7import StringIO
8import sys
9
10# Memory debug specific
11libxml2.debugMemory(1)
12
13f = StringIO.StringIO("""<a><b><c /></b><d>content of d</d></a>""")
14input = libxml2.inputBuffer(f)
15reader = input.newTextReader("test_next")
16ret = reader.Read()
17if ret != 1:
18 print "test_next: Error reading to first element"
19 sys.exit(1)
20if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
21 reader.NodeType() != 1 or reader.HasAttributes() != 0:
22 print "test_next: Error reading the first element"
23 sys.exit(1)
24ret = reader.Read()
25if ret != 1:
26 print "test_next: Error reading to second element"
27 sys.exit(1)
28if reader.Name() != "b" or reader.IsEmptyElement() != 0 or \
29 reader.NodeType() != 1 or reader.HasAttributes() != 0:
30 print "test_next: Error reading the second element"
31 sys.exit(1)
32ret = reader.Read()
33if ret != 1:
34 print "test_next: Error reading to third element"
35 sys.exit(1)
36if reader.Name() != "c" or reader.NodeType() != 1 or \
37 reader.HasAttributes() != 0:
38 print "test_next: Error reading the third element"
39 sys.exit(1)
40ret = reader.Read()
41if ret != 1:
42 print "test_next: Error reading to end of third element"
43 sys.exit(1)
44if reader.Name() != "b" or reader.NodeType() != 15:
45 print "test_next: Error reading to end of second element"
46 sys.exit(1)
47ret = reader.Next()
48if ret != 1:
49 print "test_next: Error moving to third element"
50 sys.exit(1)
51if reader.Name() != "d" or reader.IsEmptyElement() != 0 or \
52 reader.NodeType() != 1 or reader.HasAttributes() != 0:
53 print "test_next: Error reading third element"
54 sys.exit(1)
55ret = reader.Next()
56if ret != 1:
57 print "test_next: Error reading to end of first element"
58 sys.exit(1)
59if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
60 reader.NodeType() != 15 or reader.HasAttributes() != 0:
61 print "test_next: Error reading the end of first element"
62 sys.exit(1)
63ret = reader.Read()
64if ret != 0:
65 print "test_next: Error reading to end of document"
66 sys.exit(1)
67
68#
69# cleanup for memory allocation counting
70#
71del f
72del input
73del reader
74
75# Memory debug specific
76libxml2.cleanupParser()
77if libxml2.debugMemory(1) == 0:
78 print "OK"
79else:
80 print "Memory leak %d bytes" % (libxml2.debugMemory(1))
81 libxml2.dumpMemory()
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