summaryrefslogtreecommitdiff
path: root/tests/basic-types/escape-chars.vala
blob: 0e646148863eefc6bc944cbfc21f44a70f7c5963 (plain)
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
void test_x_escape_chars () {
	string s = "Copyright \xc2\xa9";

	assert (s == "Copyright ©");

	// The escape sequence \x has a variable length
	// with the lower boundary set to 1
	string s1 = "\x9q";
	assert (s1 == "\x09q");
}

void test_u_escape_chars () {
	string s = "Copyright \u00a9";

	assert (s == "Copyright ©");
}

void test_simple_escape_chars () {
	string s = "\b\f\n\r\t\v";
	s = s.escape ();
	assert (s == "\\b\\f\\n\\r\\t\\v");
	assert (s.compress () == "\b\f\n\r\t\v");
}

void main () {
	// Test case for the bug report 704709
	test_x_escape_chars ();
	test_u_escape_chars ();

	// Test case for the bug report 664689
	test_simple_escape_chars ();
}