Permalink
Browse files

a few tests

  • Loading branch information...
1 parent 9783924 commit cf7fc4eb7a197cae9f89028f60ee24719f055dbd @teepark committed May 13, 2010
Showing with 22 additions and 0 deletions.
  1. +22 −0 tests.py
View
@@ -0,0 +1,22 @@
+import unittest
+
+import lzf
+
+
+class LZFTest(object):
+ def compress(self, text):
+ # lzf guarantees that even if the compressed version is longer, it is
+ # within 104% of the original size (rounded up), so this should work
+ return lzf.compress(text, len(text) * 2)
+
+ def test_selective(self):
+ compressed = self.compress(self.VAL)
+ self.assertEqual(lzf.decompress(compressed, len(self.VAL) - 1), None)
+ assert lzf.decompress(compressed, len(self.VAL))
+
+
+class ShortString(LZFTest, unittest.TestCase):
+ VAL = "this is a test"
+
+class StringWithRepetition(LZFTest, unittest.TestCase):
+ VAL = "a longer string, repeating. " * 500

0 comments on commit cf7fc4e

Please sign in to comment.