ObjFW  Check-in [81c57d9f39]

Overview
Comment:Properly clear line in tests on failure.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 81c57d9f3914c5b8d94a41c3b28d355ceae694f1835fb89ef43c1456958ee8a4
User & Date: js on 2008-12-13 22:16:03
Other Links: manifest | tags
Context
2008-12-13
22:58
Don't compile asprintf.c if not needed. check-in: a6c1870058 user: js tags: trunk
22:16
Properly clear line in tests on failure. check-in: 81c57d9f39 user: js tags: trunk
22:09
Nicer output for OFList tests. check-in: 0425fb0d0b user: js tags: trunk
Changes

Modified tests/OFList/OFList.m from [bb00b9248d] to [4f9ae6f06a].

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
#import <string.h>
#import <wchar.h>

#import "OFString.h"
#import "OFList.h"

#define NUM_TESTS 5
#define SUCCESS							\
{								\
	wprintf(L"\r\033[1;%dmTests successful: %d/%d\033[0m",	\
	    (i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS);	\
	fflush(stdout);						\
}
#define FAIL							\
{								\
	wprintf(L"\r\033[1;31mTest %d/%d failed!\033[m\n",	\
	    i + 1, NUM_TESTS);					\
	return 1;						\
}
#define CHECK(cond)						\
	if (cond)						\
		SUCCESS						\
	else							\
		FAIL						\
	i++;
 
const wchar_t *strings[] = {
	L"First String Object",
	L"Second String Object",
	L"Third String Object"
};







|
|
|
|
|

|
|
|
|
|

|
|
|
|
|







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
#import <string.h>
#import <wchar.h>

#import "OFString.h"
#import "OFList.h"

#define NUM_TESTS 5
#define SUCCESS								\
{									\
	wprintf(L"\r\033[1;%dmTests successful: %d/%d\033[0m",		\
	    (i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS);		\
	fflush(stdout);							\
}
#define FAIL								\
{									\
	wprintf(L"\r\033[K\033[1;31mTest %d/%d failed!\033[m\n",	\
	    i + 1, NUM_TESTS);						\
	return 1;							\
}
#define CHECK(cond)							\
	if (cond)							\
		SUCCESS							\
	else								\
		FAIL							\
	i++;
 
const wchar_t *strings[] = {
	L"First String Object",
	L"Second String Object",
	L"Third String Object"
};

Modified tests/OFXMLFactory/OFXMLFactory.m from [28e322229e] to [7fe10add51].

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
	i++;

	if (!strcmp(result, should)) {
		wprintf(L"\r\033[1;%dmchar* tests successful:    %2d/%d\033[0m",
		    (i == NUM_TESTS ? 32 : 33), i, NUM_TESTS);
		fflush(stdout);
	} else {
		wprintf(L"\r\033[1;31mchar* test %d/%d failed!\033[0m\n",
		    i, NUM_TESTS);
		wprintf(L"%s is NOT expected result!\n", result);
		exit(1);
	}

	free(result);
}

inline void
check_result_wide(wchar_t *result, const wchar_t *should)
{
	i++;

	if (!wcscmp(result, should)) {
		wprintf(L"\r\033[1;%dmwchar_t* tests successful: %2d/%d\033[0m",
		    (i == NUM_TESTS ? 32 : 33), i, NUM_TESTS);
		fflush(stdout);
	} else {
		wprintf(L"\r\033[1;31mwchar_t* test %d/%d failed!\033[0m\n",
		    i, NUM_TESTS);
		wprintf(L"%s is NOT expected result!\n", result);
		exit(1);
	}

	free(result);
}








|


















|
|







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
	i++;

	if (!strcmp(result, should)) {
		wprintf(L"\r\033[1;%dmchar* tests successful:    %2d/%d\033[0m",
		    (i == NUM_TESTS ? 32 : 33), i, NUM_TESTS);
		fflush(stdout);
	} else {
		wprintf(L"\r\033[K\033[1;31mchar* test %d/%d failed!\033[0m\n",
		    i, NUM_TESTS);
		wprintf(L"%s is NOT expected result!\n", result);
		exit(1);
	}

	free(result);
}

inline void
check_result_wide(wchar_t *result, const wchar_t *should)
{
	i++;

	if (!wcscmp(result, should)) {
		wprintf(L"\r\033[1;%dmwchar_t* tests successful: %2d/%d\033[0m",
		    (i == NUM_TESTS ? 32 : 33), i, NUM_TESTS);
		fflush(stdout);
	} else {
		wprintf(L"\r\033[K\033[1;31mwchar_t* test %d/%d failed!\033[0m"
		    "\n", i, NUM_TESTS);
		wprintf(L"%s is NOT expected result!\n", result);
		exit(1);
	}

	free(result);
}