Differences From Artifact [73092aedf1]:
- File tests/OFMD5HashTests.m — part of check-in [2969086342] at 2021-04-07 21:14:36 on branch trunk — Rename OFCryptoHash -> OFCryptographicHash (user: js, size: 1577) [annotate] [blame] [check-ins using] [more...]
To Artifact [28e9fd3aee]:
- File
tests/OFMD5HashTests.m
— part of check-in
[14f1e22d79]
at
2021-05-08 23:22:59
on branch trunk
— tests: Align more with ObjFW style
ObjFW's style changed over the years, but the tests were never adjusted
to it. (user: js, size: 1613) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
17 18 19 20 21 22 23 | #include <string.h> #import "TestsAppDelegate.h" static OFString *module = @"OFMD5Hash"; | | | | | | | | | | | | | | | | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
#include <string.h>
#import "TestsAppDelegate.h"
static OFString *module = @"OFMD5Hash";
const uint8_t testFileMD5[16] =
"\x00\x8B\x9D\x1B\x58\xDF\xF8\xFE\xEE\xF3\xAE\x8D\xBB\x68\x2D\x38";
@implementation TestsAppDelegate (OFMD5HashTests)
- (void)MD5HashTests
{
void *pool = objc_autoreleasePoolPush();
OFMD5Hash *MD5, *MD5Copy;
OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
TEST(@"+[hashWithAllowsSwappableMemory:]",
(MD5 = [OFMD5Hash hashWithAllowsSwappableMemory: true]))
while (!file.atEndOfStream) {
char buffer[64];
size_t length = [file readIntoBuffer: buffer length: 64];
[MD5 updateWithBuffer: buffer length: length];
}
[file close];
TEST(@"-[copy]", (MD5Copy = [[MD5 copy] autorelease]))
TEST(@"-[digest]",
memcmp(MD5.digest, testFileMD5, 16) == 0 &&
memcmp(MD5Copy.digest, testFileMD5, 16) == 0)
EXPECT_EXCEPTION(@"Detect invalid call of "
@"-[updateWithBuffer:length]", OFHashAlreadyCalculatedException,
[MD5 updateWithBuffer: "" length: 1])
objc_autoreleasePoolPop(pool);
}
@end
|