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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
}
#define CHECK(cond) \
if (cond) \
SUCCESS \
else \
FAIL \
i++;
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 newFromCString: strings[0]]];
[list addNew: [OFString newFromCString: strings[1]]];
[list addNew: [OFString newFromCString: strings[2]]];
for (iter = [list first], i = 0; iter != nil; iter = [iter next], i++)
if (!strcmp([[iter data] cString], strings[i]))
SUCCESS
else
FAIL
CHECK(!strcmp([[[list first] data] cString], strings[0]))
CHECK(!strcmp([[[list last] data] cString], strings[2]))
puts("");
[list freeIncludingData];
return 0;
}
|
|
|
|
|
|
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
}
#define CHECK(cond) \
if (cond) \
SUCCESS \
else \
FAIL \
i++;
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 newFromCString: strings[0]]];
[list addNew: [OFString newFromCString: strings[1]]];
[list addNew: [OFString newFromCString: strings[2]]];
for (iter = [list first], i = 0; iter != nil; iter = [iter next], i++)
if (!strcmp([[iter data] cString], strings[i]))
SUCCESS
else
FAIL
CHECK(!strcmp([[[list first] data] cString], strings[0]))
CHECK(!strcmp([[[list last] data] cString], strings[2]))
puts("");
[list freeIncludingData];
return 0;
}
|