Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more useful test

  • Loading branch information...
commit 7643f217942a52ab228763e45700e79ebc4c3e0c 1 parent b3ed6be
@fat-crocodile authored
Showing with 14 additions and 9 deletions.
  1. +14 −9 lzo/lzo_test.py
View
23 lzo/lzo_test.py
@@ -4,8 +4,12 @@
import lzo
from mylzo1x_d import lzo1x_decoder
+# level 1 -- lzo1x_1
+# 2-9 -- lzo1x_999
+level = int(sys.argv[1]) if len(sys.argv) > 1 else 1
+
plain_text = sys.stdin.read()
-compressed = lzo.compress(plain_text)
+compressed = lzo.compress(plain_text, level)
log = []
res = ''.join(lzo1x_decoder(compressed[5:], log.append))
@@ -13,15 +17,16 @@
# print some results
print "plain text len = %d, compressed len = %d, decopressed len = %d" % (len(plain_text), len(compressed), len(res))
-count = 0
-for i in xrange(len(plain_text)):
- if plain_text[i] != res[i]:
- print 'error %d: at %d, %d vs. %d' % (count, i, ord(plain_text[i]), ord(res[i]))
- count += 1
- if count > 10: break
-
-if count == 0:
+if plain_text == ''.join(res):
print 'OK'
+else:
+ # print first 10 errors
+ count = 0
+ for i in xrange(len(plain_text)):
+ if plain_text[i] != res[i]:
+ print 'error %d: at %d, %d vs. %d' % (count, i, ord(plain_text[i]), ord(res[i]))
+ count += 1
+ if count > 10: break
# print complete log in stderr
for r in log:
Please sign in to comment.
Something went wrong with that request. Please try again.