25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#import "OFHashAlreadyCalculatedException.h"
#import "TestsAppDelegate.h"
static OFString *module = @"OFHash";
const uint8_t testfile_sha1[OF_SHA1_DIGEST_SIZE] =
"\xC9\x9A\xB8\x7E\x1E\xC8\xEC\x65\xD5\xEB\xE4\x2E\x0D\xA6\x80\x96\xF5"
"\x94\xE7\x17";
@implementation TestsAppDelegate (SHA1HashTests)
- (void)SHA1HashTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#import "OFHashAlreadyCalculatedException.h"
#import "TestsAppDelegate.h"
static OFString *module = @"OFHash";
const uint8_t testfile_sha1[20] =
"\xC9\x9A\xB8\x7E\x1E\xC8\xEC\x65\xD5\xEB\xE4\x2E\x0D\xA6\x80\x96\xF5"
"\x94\xE7\x17";
@implementation TestsAppDelegate (SHA1HashTests)
- (void)SHA1HashTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
size_t len = [f readIntoBuffer: buf
length: 64];
[sha1 updateWithBuffer: buf
length: len];
}
[f close];
TEST(@"-[digest]",
!memcmp([sha1 digest], testfile_sha1, OF_SHA1_DIGEST_SIZE))
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException,
[sha1 updateWithBuffer: ""
length: 1])
[pool drain];
}
@end
|
|
<
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
size_t len = [f readIntoBuffer: buf
length: 64];
[sha1 updateWithBuffer: buf
length: len];
}
[f close];
TEST(@"-[digest]", !memcmp([sha1 digest], testfile_sha1, 20))
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length:]", OFHashAlreadyCalculatedException,
[sha1 updateWithBuffer: ""
length: 1])
[pool drain];
}
@end
|