ObjFW  Check-in [6d6ac5a6d5]

Overview
Comment:Migration of OFHashes tests to new testing framework.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6d6ac5a6d569873b0bf98b193d87cdc0209ca9f9a16561452bdcc6cff94a3242
User & Date: js on 2009-09-30 15:43:34
Other Links: manifest | tags
Context
2009-10-01
07:51
Fix stupid gcc warning that only appears on OS X. check-in: 63b90ff39d user: js tags: trunk
2009-09-30
15:43
Migration of OFHashes tests to new testing framework. check-in: 6d6ac5a6d5 user: js tags: trunk
15:01
Migration of OFDataArray tests to new testing framework. check-in: e7a372fea9 user: js tags: trunk
Changes

Modified tests/Makefile from [e430b80025] to [2ad5747ae0].

1
2
3
4
5
6
7
8
9
include ../extra.mk

SUBDIRS = OFHashes		\
	  ${OFPLUGIN}		\
	  OFThread		\
	  OFXMLParser		\
	  ${OBJC_SYNC}

include ../buildsys.mk


<
|





1
2

3
4
5
6
7
8
include ../extra.mk


SUBDIRS = ${OFPLUGIN}		\
	  OFThread		\
	  OFXMLParser		\
	  ${OBJC_SYNC}

include ../buildsys.mk

Deleted tests/OFHashes/Makefile version [6b83c355e5].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
PROG_NOINST = ofhashes${PROG_SUFFIX}
SRCS = OFHashes.m

include ../../buildsys.mk
include ../../extra.mk

CPPFLAGS += -I../../src -I../..
LIBS := -L../../src -lobjfw ${LIBS}

.PHONY: run

all: run
run: ${PROG_NOINST}
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib
	if test -f ../../src/libobjfw.so; then \
		ln -s ../../src/libobjfw.so libobjfw.so.0; \
		ln -s ../../src/libobjfw.so libobjfw.so.0.1; \
	fi
	if test -f ../../src/libobjfw.dll; then \
		ln ../../src/libobjfw.dll libobjfw.dll; \
	fi
	if test -f ../../src/libobjfw.dylib; then \
		ln -s ../../src/libobjfw.dylib libobjfw.dylib; \
	fi
	LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
	DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
	${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \
	exit $$EXIT
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































Deleted tests/OFHashes/OFHashes.m version [b3e57d0d68].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
57
58
59
60
61
62
63
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#include <stdio.h>
#include <string.h>

#import "OFHashes.h"
#import "OFFile.h"

const uint8_t testfile_md5[OF_MD5_DIGEST_SIZE] =
    "\x00\x8B\x9D\x1B\x58\xDF\xF8\xFE\xEE\xF3\xAE\x8D\xBB\x68\x2D\x38";
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";

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

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

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

	if (!memcmp([md5 digest], testfile_md5, OF_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, OF_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;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































Deleted tests/OFHashes/testfile version [ac78121630].

cannot compute difference between binary files

Modified tests_new/Makefile from [2046040715] to [cac1badf65].

1
2
3
4

5
6
7
8
9
10
11
PROG_NOINST = tests${PROG_SUFFIX}
SRCS = array.m		\
       dataarray.m	\
       dictionary.m	\

       list.m		\
       main.m		\
       object.m		\
       string.m		\
       tcpsocket.m	\
       xmlelement.m





>







1
2
3
4
5
6
7
8
9
10
11
12
PROG_NOINST = tests${PROG_SUFFIX}
SRCS = array.m		\
       dataarray.m	\
       dictionary.m	\
       hashes.m		\
       list.m		\
       main.m		\
       object.m		\
       string.m		\
       tcpsocket.m	\
       xmlelement.m

Added tests_new/hashes.m version [fbd0b08278].



























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
57
58
59
60
61
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#include <string.h>

#import "OFHashes.h"
#import "OFFile.h"
#import "OFAutoreleasePool.h"
#import "OFString.h"
#import "OFExceptions.h"

#import "main.h"

static OFString *module = @"OFHashes";

const uint8_t testfile_md5[OF_MD5_DIGEST_SIZE] =
	"\x00\x8B\x9D\x1B\x58\xDF\xF8\xFE\xEE\xF3\xAE\x8D\xBB\x68\x2D\x38";
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";

void
hashes_tests()
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMD5Hash *md5;
	OFSHA1Hash *sha1;
	OFFile *f = [OFFile fileWithPath: @"testfile"
				    mode: @"rb"];

	TEST(@"+[md5Hash]", (md5 = [OFMD5Hash md5Hash]))

	TEST(@"+[sha1Hash]", (sha1 = [OFSHA1Hash sha1Hash]))

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

	TEST(@"-[digest]",
	    !memcmp([md5 digest], testfile_md5, OF_MD5_DIGEST_SIZE) &&
	    !memcmp([sha1 digest], testfile_sha1, OF_MD5_DIGEST_SIZE))

	[pool release];
}

Modified tests_new/main.m from [d8a71e2ba4] to [44c304cc3d].

18
19
20
21
22
23
24

25
26
27
28
29
30
31

#import "OFString.h"
#import "OFAutoreleasePool.h"

extern void array_tests();
extern void dataarray_tests();
extern void dictionary_tests();

extern void list_tests();
extern void object_tests();
extern void string_tests();
extern void tcpsocket_tests();
extern void xmlelement_tests();

static int fails = 0;







>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#import "OFString.h"
#import "OFAutoreleasePool.h"

extern void array_tests();
extern void dataarray_tests();
extern void dictionary_tests();
extern void hashes_tests();
extern void list_tests();
extern void object_tests();
extern void string_tests();
extern void tcpsocket_tests();
extern void xmlelement_tests();

static int fails = 0;
88
89
90
91
92
93
94

95
96
97
98
99
100
101
102
103
104
	[pool release];
}

int
main()
{
	object_tests();

	string_tests();
	dataarray_tests();
	array_tests();
	dictionary_tests();
	list_tests();
	tcpsocket_tests();
	xmlelement_tests();

	return fails;
}







>










89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
	[pool release];
}

int
main()
{
	object_tests();
	hashes_tests();
	string_tests();
	dataarray_tests();
	array_tests();
	dictionary_tests();
	list_tests();
	tcpsocket_tests();
	xmlelement_tests();

	return fails;
}

Added tests_new/testfile version [ac78121630].

cannot compute difference between binary files

Modified tests_new/xmlelement.m from [374a7a3822] to [c815e882b3].

39
40
41
42
43
44
45
46
47
48
49
50
51
	    [elem[0] addAttributeWithName: @"foo"
			      stringValue: @"b&ar"] &&
	    [[elem[0] string] isEqual: @"<foo foo='b&amp;ar'/>"] &&
	    [elem[1] addAttributeWithName: @"foo"
			      stringValue: @"b&ar"] &&
	    [[elem[1] string] isEqual: @"<foo foo='b&amp;ar'>b&amp;ar</foo>"])

	TEST(@"-[addChild",
	    [elem[0] addChild: [OFXMLElement elementWithName: @"bar"]] &&
	    [[elem[0] string] isEqual: @"<foo foo='b&amp;ar'><bar/></foo>"])

	[pool release];
}







|





39
40
41
42
43
44
45
46
47
48
49
50
51
	    [elem[0] addAttributeWithName: @"foo"
			      stringValue: @"b&ar"] &&
	    [[elem[0] string] isEqual: @"<foo foo='b&amp;ar'/>"] &&
	    [elem[1] addAttributeWithName: @"foo"
			      stringValue: @"b&ar"] &&
	    [[elem[1] string] isEqual: @"<foo foo='b&amp;ar'>b&amp;ar</foo>"])

	TEST(@"-[addChild:]",
	    [elem[0] addChild: [OFXMLElement elementWithName: @"bar"]] &&
	    [[elem[0] string] isEqual: @"<foo foo='b&amp;ar'><bar/></foo>"])

	[pool release];
}