summaryrefslogtreecommitdiff
path: root/lib/std/test/utf.myr
blob: 9f73f5ae4ad47ef9e5e59ae9e218613928123a85 (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
use std

const main = {
	/* Raw ASCII */
	std.assert(std.strcellwidth("foobar") == 6, "wrong width of \"foobar\"")
	std.assert(std.strcellwidth("") == 0, "wrong width of \"\"")

	/* Control characters */
	var ab = [ (0x63 : byte), (0x00 : byte), (0x64 : byte) ][:]
	std.assert(std.strcellwidth(ab) == 2, "wrong width of \"a^@b\"")

	/* Accents and combining marks */
	std.assert(std.strcellwidth("Αυτό") == 4, "wrong width of \"Αυτό")
	std.assert(std.strcellwidth("ŗšțūžäñ") == 7, "wrong width of \"ŗšțūžäñ")
	std.assert(std.strcellwidth("c̸̶̡̡̗̣͕̪͖ͯ͑̈̄̿͊ͣ̈́͝ḧ̵̸̛̥͚̭̣͈͖̼͈͓͓̫͍́̓ͪͫ̋͘͡a̢̩̱̠̘̹̤̯͚̦̰̼̯̲̞͆͂̿ͬ̂͋͒̈ͅͅo̷̷̶̥͖̼̮̳̗͚ͦ̉̆̅̃̍ͤ̆͑ͣ̽́̚s̓̍̍̄͏̖̞̟̱́͡͡͝") == 5, "wrong width of \"c̸̶̡̡̗̣͕̪͖ͯ͑̈̄̿͊ͣ̈́͝ḧ̵̸̛̥͚̭̣͈͖̼͈͓͓̫͍́̓ͪͫ̋͘͡a̢̩̱̠̘̹̤̯͚̦̰̼̯̲̞͆͂̿ͬ̂͋͒̈ͅͅo̷̷̶̥͖̼̮̳̗͚ͦ̉̆̅̃̍ͤ̆͑ͣ̽́̚s̓̍̍̄͏̖̞̟̱́͡͡͝\"")
	std.assert(std.strcellwidth("q̆") == 1, "wrong width of \"q̆\"")
	std.assert(std.strcellwidth(" ͝ ⃔ ⃫") == 3, "wrong width of \" ͝ ⃔ ⃫\"")
	std.assert(std.strcellwidth("f⃫⃔͝") == 1, "wrong width of \"f⃫⃔͝\"")

	/* Non-Latin scripts */
	std.assert(std.strcellwidth("Οὐχὶ ταὐτὰ παρίσταταί") == 21, \
		"wrong width of Greek")
	std.assert(std.strcellwidth("Я человек больной...") == 20, \
		"wrong width of Cyrillic")
	std.assert(std.strcellwidth("銀河の歴史がまた1ページ") == 23, \
		"wrong width of CJK")
	std.assert(std.strcellwidth("ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ") == 19, \
		"wrong width of runes")
	std.assert(std.strcellwidth("𒀸 𒌋𒅗 𒆷 𒂅𒌒 𒍜 𒀭𒉌𒄿 𒈗 𒁁𒉌 𒋬") == 22, \
		"wrong width of Cuneiform")
}