[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Improve svn_checksum_t bindings in SWIG

From: Peter Samuelson <peter_at_p12n.org>
Date: Tue, 11 Dec 2012 12:49:27 -0600

> > +LENGTH = svn.core.svn_checksum_size(svn.core.svn_checksum_create(svn.core.svn_checksum_md5))

> > + self.assertEqual(len(check_val)%LENGTH,0,"Length of digest does not match kind")

Is there a better way to get the expected length?
svn.core.svn_checksum_create(svn.core.svn_checksum_md5) is called twice
here. If we had an off-by-one bug in the length of the object returned
from svn_checksum_create, this test wouldn't catch it.

I know others have said not to hardcode a 32 here. But you're already
hardcoding MD5. I'd say if there's no other convenient alternative,
hardcoding the knowledge that "md5 is 128 bits" (32 hex digits) seems
better than testing that two objects created by the same constructor
are the same length.

I mean, to extend this test to other checksum kinds would require
something of a rewrite anyway.
Received on 2012-12-11 19:50:05 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.