@@ -35,11 +35,11 @@ @implementation TestsAppDelegate (SHA1HashTests) - (void)SHA1HashTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - OFSHA1Hash *sha1; + OFSHA1Hash *sha1, *copy; OFFile *f = [OFFile fileWithPath: @"testfile.bin" mode: @"rb"]; TEST(@"+[cryptoHash]", (sha1 = [OFSHA1Hash cryptoHash])) @@ -50,15 +50,19 @@ [sha1 updateWithBuffer: buf length: len]; } [f close]; - TEST(@"-[digest]", !memcmp([sha1 digest], testfile_sha1, 20)) + TEST(@"-[copy]", (copy = [[sha1 copy] autorelease])) + + TEST(@"-[digest]", + memcmp([sha1 digest], testfile_sha1, 20) == 0 && + memcmp([copy digest], testfile_sha1, 20) == 0) EXPECT_EXCEPTION(@"Detect invalid call of " @"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException, [sha1 updateWithBuffer: "" length: 1]) [pool drain]; } @end