ObjFW  Check-in [722bb97765]

Overview
Comment:Automatic test for OFList.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 722bb9776590741a5a0f7ffb675204fb2612615099a651e04fccfdf029f83261
User & Date: js on 2008-09-14 18:35:22
Other Links: manifest | tags
Context
2008-09-14
19:03
More exceptions stuff. check-in: 98fe076bd8 user: js tags: trunk
18:35
Automatic test for OFList. check-in: 722bb97765 user: js tags: trunk
18:26
Automatic tests for OFString and OFWideString. check-in: dd22ec2c8e user: js tags: trunk
Changes

Modified tests/OFList/OFList.m from [e065d3f792] to [106c4c0f9c].

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
/*
 * Copyright (c) 2008
 *   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.
 */

#import <stdio.h>


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

/* TODO: Do real checks */
 






int
main()
{

	OFList	     *list;
	OFListObject *iter;

	list = [OFList new];
 
	[list addNew: [OFString new: "First String Object"]];
	[list addNew: [OFString new: "Second String Object"]];
	[list addNew: [OFString new: "Third String Object"]];
 
	for (iter = [list first]; iter != nil; iter = [iter next])
		printf("%s\n", [(OFString*)[iter data] cString]);



















 
	[iter free];
	[list free];

	return 0;
}












>






>
>
>
>
>
>



>





|
|
|

|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






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
64
65
/*
 * Copyright (c) 2008
 *   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.
 */

#import <stdio.h>
#import <string.h>

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

/* TODO: Do real checks */
 
const char *strings[] = {
	"First String Object",
	"Second String Object",
	"Third String Object"
};

int
main()
{
	size_t	     i;
	OFList	     *list;
	OFListObject *iter;

	list = [OFList new];
 
	[list addNew: [OFString new: strings[0]]];
	[list addNew: [OFString new: strings[1]]];
	[list addNew: [OFString new: strings[2]]];
 
	for (iter = [list first], i = 0; iter != nil; iter = [iter next], i++)
		if (!strcmp([(OFString*)[iter data] cString], strings[i]))
			printf("Element %zd is expected element. GOOD!\n", i);
		else {
			printf("Element %zd is not expected element!\n", i);
			return 1;
		}

	if (!strcmp([(OFString*)[[list first] data] cString], strings[0]))
		puts("First element is expected element. GOOD!");
	else {
		puts("First element is not expected element!");
		return 1;
	}

	if (!strcmp([(OFString*)[[list last] data] cString], strings[2]))
		puts("Last element is expected element. GOOD!");
	else {
		puts("Last element is not expected element!");
		return 1;
	}
 
	[iter free];
	[list free];

	return 0;
}