ObjFW  Diff

Differences From Artifact [9258edbe28]:

To Artifact [38ab25865c]:


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
#import "OFString.h"

/* TODO: Do real checks */

int
main()
{
	OFString *s1 = [OFString new: "foo"];
	OFString *s2 = [[OFString alloc] init: ""];
	OFString *s3;
	OFString *s4 = [OFString new];

	[s2 append: "bar"];
	s3 = [s1 clone];

	[s4 setTo: [s2 cString]];

	printf("s1 = %s\n", [s1 cString]);
	printf("s2 = %s\n", [s2 cString]);




	printf("s3 = %s\n", [s3 cString]);
	printf("s4 = %s\n", [s4 cString]);






	[s1 append: [s2 cString]];
	printf("s1 append s2 = %s\n", [s1 cString]);




	printf("strlen(s1) = %zd, [s1 length] = %zd\n",
	    strlen([s1 cString]), [s1 length]);






	[s1 free];
	[s2 free];
	[s3 free];
	[s4 free];

	return 0;
}







|




|




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







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
66
#import "OFString.h"

/* TODO: Do real checks */

int
main()
{
	OFString *s1 = [OFString new: "test"];
	OFString *s2 = [[OFString alloc] init: ""];
	OFString *s3;
	OFString *s4 = [OFString new];

	[s2 append: "123"];
	s3 = [s1 clone];

	[s4 setTo: [s2 cString]];

	if (!strcmp([s1 cString], [s3 cString]))
		puts("s1 and s3 match! GOOD!");
	else {
		puts("s1 and s3 don't match!");
		return 1;
	}

	if (!strcmp([s2 cString], [s4 cString]))
		puts("s2 and s4 match! GOOD!");
	else {
		puts("s1 and s3 don't match!");
		return 1;
	}

	if (!strcmp([[s1 append: [s2 cString]] cString], "test123"))
		puts("s1 appended with s2 is the expected string! GOOD!");
	else {
		puts("s1 appended with s2 is not the expected string!");
		return 1;
	}

	if (strlen([s1 cString]) == [s1 length] && [s1 length] == 7)
		puts("s1 has the expected length. GOOD!");
	else {
		puts("s1 does not have the expected length!");
		return 1;
	}

	[s1 free];
	[s2 free];
	[s3 free];
	[s4 free];

	return 0;
}