summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-06-27 20:24:33 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-06-27 20:24:33 +0000
commit47d557924d91f6003ebbecb29bb29ffec02c1f07 (patch)
tree7954249018b280b9be426485e7a229717e087a8f
parentb12c8c861ee1be9fd157212cdd9cca1d6e1e127d (diff)
downloadrdiff-backup-47d557924d91f6003ebbecb29bb29ffec02c1f07.tar.gz
Unit tests for cmodule
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@153 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/testing/ctest.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/rdiff-backup/testing/ctest.py b/rdiff-backup/testing/ctest.py
new file mode 100644
index 0000000..d5f0751
--- /dev/null
+++ b/rdiff-backup/testing/ctest.py
@@ -0,0 +1,41 @@
+import unittest
+from commontest import *
+from C import *
+from rpath import *
+
+class CTest(unittest.TestCase):
+ """Test the C module by comparing results to python functions"""
+ def test_make_dict(self):
+ """Test making stat dictionaries"""
+ rp1 = RPath(Globals.local_connection, "/dev/ttyS1")
+ rp2 = RPath(Globals.local_connection, "./ctest.py")
+ rp3 = RPath(Globals.local_connection, "aestu/aeutoheu/oeu")
+ rp4 = RPath(Globals.local_connection, "testfiles/various_file_types/symbolic_link")
+ rp5 = RPath(Globals.local_connection, "testfiles/various_file_types/fifo")
+
+ for rp in [rp1, rp2, rp3, rp4, rp5]:
+ dict1 = rp.make_file_dict_old()
+ dict2 = C.make_file_dict(rp.path)
+ if dict1 != dict2:
+ print "Python dictionary: ", dict1
+ print "not equal to C dictionary: ", dict2
+ print "for path ", rp.path
+ assert 0
+
+ def test_strlong(self):
+ """Test str2long and long2str"""
+ self.assertRaises(TypeError, C.long2str, "hello")
+ self.assertRaises(TypeError, C.str2long, 34)
+ self.assertRaises(TypeError, C.str2long, "oeuo")
+ self.assertRaises(TypeError, C.str2long, "oeuoaoeuaoeu")
+
+ for s in ["\0\0\0\0\0\0\0", "helloto",
+ "\xff\xff\xff\xff\xff\xff\xff", "randoms"]:
+ assert len(s) == 7, repr(s)
+ s_out = C.long2str(C.str2long(s))
+ assert s_out == s, (s_out, C.str2long(s), s)
+ for l in 0L, 1L, 4000000000L, 34234L, 234234234L:
+ assert C.str2long(C.long2str(l)) == l
+
+
+if __name__ == "__main__": unittest.main()