HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Nougat 7.0
|
7.0.0_r31
下载
查看原文件
收藏
根目录
external
libxml2
python
tests
indexes.py
#!/usr/bin/python -u # -*- coding: ISO-8859-1 -*- import sys import libxml2 # Memory debug specific libxml2.debugMemory(1) ctxt = None class callback: def __init__(self, startd, starte, ende, delta, endd): self.startd = startd self.starte = starte self.ende = ende self.endd = endd self.delta = delta self.count = 0 def startDocument(self): global ctxt if ctxt.byteConsumed() != self.startd: print("document start at wrong index: %d expecting %d\n" % ( ctxt.byteConsumed(), self.startd)) sys.exit(1) def endDocument(self): global ctxt expect = self.ende + self.delta * (self.count - 1) + self.endd if ctxt.byteConsumed() != expect: print("document end at wrong index: %d expecting %d\n" % ( ctxt.byteConsumed(), expect)) sys.exit(1) def startElement(self, tag, attrs): global ctxt if tag == "bar1": expect = self.starte + self.delta * self.count if ctxt.byteConsumed() != expect: print("element start at wrong index: %d expecting %d\n" % ( ctxt.byteConsumed(), expect)) sys.exit(1) def endElement(self, tag): global ctxt if tag == "bar1": expect = self.ende + self.delta * self.count if ctxt.byteConsumed() != expect: print("element end at wrong index: %d expecting %d\n" % ( ctxt.byteConsumed(), expect)) sys.exit(1) self.count = self.count + 1 def characters(self, data): pass # # First run a pure UTF-8 test # handler = callback(0, 13, 27, 198, 183) ctxt = libxml2.createPushParser(handler, "
\n", 6, "test.xml") chunk = """
chars1
chars2
chars3
chars4
chars5
<s6
chars7
&8
chars9
""" i = 0 while i < 10000: ctxt.parseChunk(chunk, len(chunk), 0) i = i + 1 chunk = "
" ctxt.parseChunk(chunk, len(chunk), 1) ctxt=None # # Then run a test relying on ISO-Latin-1 # handler = callback(43, 57, 71, 198, 183) chunk="""
""" ctxt = libxml2.createPushParser(handler, chunk, len(chunk), "test.xml") chunk = """
chars1
chars2
chars3
chrs4
chars5
<s6
chars7
&8
trs 9
""" i = 0 while i < 10000: ctxt.parseChunk(chunk, len(chunk), 0) i = i + 1 chunk = "
" ctxt.parseChunk(chunk, len(chunk), 1) ctxt=None # Memory debug specific libxml2.cleanupParser() if libxml2.debugMemory(1) == 0: print("OK") else: print("Memory leak %d bytes" % (libxml2.debugMemory(1))) libxml2.dumpMemory()
普通文本
|
114行
|
2.9 KB
原始内容
高亮显示
复制内容
×
已收藏
收藏成功,您可以在我收藏的代码页面中查看,其地址为:
https://www.androidos.net.cn/my/collect/code
。
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册