ObjFW  Diff

Differences From Artifact [4cc440481a]:

To Artifact [c778845c1b]:


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
57
58
59
60
61
62
63
64
65

int
main()
{
	uint8_t buf[64];
	size_t	len;

	OFMD5Hash  *md5  = [OFMD5Hash new];
	OFSHA1Hash *sha1 = [OFSHA1Hash new];
	OFFile *f = [OFFile newWithPath: "testfile"
				andMode: "rb"];

	while (![f atEndOfFile]) {
		len = [f readNBytes: 64
			 intoBuffer: buf];
		[md5 updateWithBuffer: buf
			       ofSize: len];
		[sha1 updateWithBuffer: buf
				ofSize: len];
	}
	[f free];

	if (!memcmp([md5 digest], testfile_md5, MD5_DIGEST_SIZE)) {
		fputs("\r\033[1;33mTests successful: 1/2\033[0m", stdout);
		fflush(stdout);
	} else {
		puts("\r\033[K\033[1;31mTest 1/2 failed!\033[0m");
		return 1;
	}
	[md5 free];

	if (!memcmp([sha1 digest], testfile_sha1, SHA1_DIGEST_SIZE))
		puts("\r\033[1;32mTests successful: 2/2\033[0m");
	else {
		puts("\r\033[K\033[1;31mTest 2/2 failed!\033[0m");
		return 1;
	}
	[sha1 free];

	return 0;
}







|
|
|
|









|








<







<



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
57
58
59
60

61
62
63

int
main()
{
	uint8_t buf[64];
	size_t	len;

	OFMD5Hash  *md5  = [OFMD5Hash md5Hash];
	OFSHA1Hash *sha1 = [OFSHA1Hash sha1Hash];
	OFFile *f = [OFFile fileWithPath: "testfile"
				 andMode: "rb"];

	while (![f atEndOfFile]) {
		len = [f readNBytes: 64
			 intoBuffer: buf];
		[md5 updateWithBuffer: buf
			       ofSize: len];
		[sha1 updateWithBuffer: buf
				ofSize: len];
	}
	[f close];

	if (!memcmp([md5 digest], testfile_md5, MD5_DIGEST_SIZE)) {
		fputs("\r\033[1;33mTests successful: 1/2\033[0m", stdout);
		fflush(stdout);
	} else {
		puts("\r\033[K\033[1;31mTest 1/2 failed!\033[0m");
		return 1;
	}


	if (!memcmp([sha1 digest], testfile_sha1, SHA1_DIGEST_SIZE))
		puts("\r\033[1;32mTests successful: 2/2\033[0m");
	else {
		puts("\r\033[K\033[1;31mTest 2/2 failed!\033[0m");
		return 1;
	}


	return 0;
}