Log:
[[[ Followup to r1420334: Adding new tests.

* subversiom/bindings/swig/python/tests/checksum.py
Writing new tests to ensure robustness of svn_checksum_match(),
svn_checksum_dup() and svn_checksum_empty_checksum().

Patch by: Shivani Poddar <shivani.podda...@gmail.com> ]]]


Regards,
Shivani Poddar,
irc-nick - trinity_28
IIIT-Hyderabad.



-- 
Shivani Poddar,
Bachelors in Computer Sciences and MS in Exact Humanities, Sophomore
International Institute of Information Technology, Hyderabad
Index: subversion/bindings/swig/python/tests/checksum.py
===================================================================
--- subversion/bindings/swig/python/tests/checksum.py   (revision 1448005)
+++ subversion/bindings/swig/python/tests/checksum.py   (working copy)
@@ -28,14 +28,50 @@
         kind, expected_length = svn.core.svn_checksum_md5, 128/8
         val = svn.core.svn_checksum_create(kind)
         check_val = svn.core.svn_checksum_to_cstring_display(val)
-
+        rand_checksum = svn.core.svn_checksum_t()
+        rand_checksum.digest  = 'd41d8cd98f00b204e9800998ecf8427e'
+        rand_checksum2 = svn.core.svn_checksum_t()
+        rand_checksum2.digest = '568554e2bf0fc50aa347777731081a80'
+        #They are preset to kind = 0
+        check_rand = svn.core.svn_checksum_to_cstring(rand_checksum)
+        duplicate = svn.core.svn_checksum_dup(rand_checksum)
+        duplicate_val = svn.core.svn_checksum_dup(val)
+        check_rand2 = svn.core.svn_checksum_to_cstring(rand_checksum2)
+        check_dup = svn.core.svn_checksum_to_cstring(duplicate)
         self.assertTrue(isinstance(check_val, str),
-                              "Type of digest not string")
+                        "Type of digest not string")
         self.assertEqual(len(check_val), 2*expected_length,
-                         "Length of digest does not match kind")
+                        "Length of digest does not match kind")
         self.assertEqual(int(check_val), 0,
-                         "Value of initialized digest is not 0")
+                        "Value of initialized digest is not 0")
+        #Checking the svn_checksum_dup() function's returned object's 
attributes
+        self.assertEqual(type(rand_checksum),type(duplicate),
+                        "Duplicate checksum returned is not of the type 
svn_checksum_t*")
+        self.assertEqual(rand_checksum.kind,duplicate.kind,
+                        "Duplicate returned is not of the same 
svn_checksum_kind_t as the parent checksum")
+        self.assertEqual(check_rand,check_dup,
+                        "Duplicate returned does not have the same digest 
value as the parent checksum")
+        #Checking svn_checksum_match()
+        #Unequal checksums rand_checksum and rand_checksum2
+        
self.assertEqual(str(svn.core.svn_checksum_match(rand_checksum2,rand_checksum)),'0',
+                        "Unequal checksums return match")
+        #Duplicate non zero checksums
+        
self.assertIs(str(svn.core.svn_checksum_match(rand_checksum,duplicate)),'1',
+                        "Equal Checksums return false for checksum match")
+        #Border case to check if match returns a zero for all checksums
+        self.assertIs(str(svn.core.svn_checksum_match(val,duplicate_val)),'1',
+                        "Zero checksums should return 1 in svn_checksum_match")
+        #Checking for 1 zero and 1 non zero checksum
+        self.assertIs(str(svn.core.svn_checksum_match(val,rand_checksum)),'1',
+                        "0 not returned for zero checksum argument in 
svn_checksum_match")
 
+        #Testing for svn_checksum_is_empty_checksum()
+        #Checking for an empty checksum
+        self.assertEqual(str(svn.core.svn_checksum_is_empty_checksum(val)),'1',
+                        "False is returned for svn_checksum_is_empty_checksum 
for empty checksum")
+        #Checking for a non-empty checksum
+        
self.assertEqual(str(svn.core.svn_checksum_is_empty_checksum(rand_checksum)),'0',
+                        "True is returned for svn_checksum_is_empty_checksum 
for non-empty checksum")
 def suite():
     return unittest.defaultTestLoader.loadTestsFromTestCase(ChecksumTestCases)
 

Reply via email to