| 1 |
root |
1.2 |
BEGIN { $| = 1; print "1..5\n"; } |
| 2 |
root |
1.1 |
END {print "not ok 1\n" unless $loaded;} |
| 3 |
|
|
use AnyEvent::MCP; |
| 4 |
|
|
$loaded = 1; |
| 5 |
|
|
print "ok 1\n"; |
| 6 |
root |
1.2 |
|
| 7 |
|
|
my $text = "\x{e4}\x{1f642}"; |
| 8 |
|
|
my $bytes = AnyEvent::MCP::utf8enc $text; |
| 9 |
|
|
print $bytes eq "\xc3\xa4\xf0\x9f\x99\x82" |
| 10 |
|
|
? "ok 2 - encode UTF-8\n" : "not ok 2 - encode UTF-8\n"; |
| 11 |
|
|
print AnyEvent::MCP::utf8dec ($bytes) eq $text |
| 12 |
|
|
? "ok 3 - decode UTF-8\n" : "not ok 3 - decode UTF-8\n"; |
| 13 |
|
|
print $text eq "\x{e4}\x{1f642}" |
| 14 |
|
|
? "ok 4 - source is unchanged\n" : "not ok 4 - source is unchanged\n"; |
| 15 |
|
|
eval { AnyEvent::MCP::utf8dec ("\xff") }; |
| 16 |
|
|
print $@ ? "ok 5 - reject invalid UTF-8\n" : "not ok 5 - reject invalid UTF-8\n"; |