ObjFW  Diff

Differences From Artifact [acd4c64051]:

To Artifact [09c95b9e26]:


11
12
13
14
15
16
17

18
19
20
21
22
23
24

#import "config.h"

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

#import "OFString.h"


int
main()
{
	OFString *s1 = [OFString newFromCString: "test"];
	OFString *s2 = [OFString newFromCString: ""];
	OFString *s3;







>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#import "config.h"

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

#import "OFString.h"
#import "OFExceptions.h"

int
main()
{
	OFString *s1 = [OFString newFromCString: "test"];
	OFString *s2 = [OFString newFromCString: ""];
	OFString *s3;
79
80
81
82
83
84
85
86



























87
88
	}

	/* Also clears all the memory of the returned C strings */
	[s1 free];
	[s2 free];
	[s3 free];
	[s4 free];




























	return 0;
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
	}

	/* Also clears all the memory of the returned C strings */
	[s1 free];
	[s2 free];
	[s3 free];
	[s4 free];

	/* UTF-8 tests */
	@try {
		s1 = [OFString newFromCString: "\xE0\x80"];

		puts("First invalid UTF-8 not detected!");
		return 1;
	} @catch (OFInvalidEncodingException *e) {
		puts("First invalid UTF-8 successfully detected!");
	}

	@try {
		s1 = [OFString newFromCString: "\xF0\x80\x80\xC0"];

		puts("Second UTF-8 not detected!");
		return 1;
	} @catch (OFInvalidEncodingException *e) {
		puts("Second UTF-8 successfully detected!");
	}

	s1 = [OFString newFromCString: "äöü€𝄞"];
	if (!strcmp([[s1 reverse] cString], "𝄞€üöä"))
		puts("Reversed UTF-8 string is expected string! GOOD!");
	else {
		puts("Reversed UTF-8 string is NOT expected string!");
		return 1;
	}

	return 0;
}