diff options
author | Karl Williamson <public@khwilliamson.com> | 2013-03-27 18:17:28 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2014-12-11 11:28:30 -0700 |
commit | d5b98071c9e3e7e1d15e5358ad2316f3928fb05d (patch) | |
tree | 9ab719289d13e1fb92f82f153a6b60ed6575dc61 | |
parent | 0505367018ffb2b76ed4195671cb41f05d198990 (diff) | |
download | perl-d5b98071c9e3e7e1d15e5358ad2316f3928fb05d.tar.gz |
Add test that to/from native character set works
For non-ASCII systems, there are character set translation tables. This
makes sure the two accessible ones are inverses of each other. If not,
nothing can be expected to work right.
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | t/base/translate.t | 27 |
2 files changed, 28 insertions, 0 deletions
@@ -4917,6 +4917,7 @@ t/base/num.t See if numbers work t/base/pat.t See if pattern matching works t/base/rs.t See if record-read works t/base/term.t See if various terms work +t/base/translate.t See if character set translation works t/base/while.t See if while work t/benchmark/rt26188-speed-up-keys-on-empty-hash.t Benchmark if keys on empty hashes is fast enough t/bigmem/index.t Check that index() handles large offsets diff --git a/t/base/translate.t b/t/base/translate.t new file mode 100644 index 0000000000..614f22c9c6 --- /dev/null +++ b/t/base/translate.t @@ -0,0 +1,27 @@ +#!./perl + +# Verify round trip of translations from the native character set to unicode +# and back work. If this is wrong, nothing will be reliable. + +print "1..257\n"; # 0-255 plus one beyond + +for my $i (0 .. 255) { + my $uni = utf8::native_to_unicode($i); + if ($uni < 0 || $uni >= 256) { + print "not "; + } + elsif (utf8::unicode_to_native(utf8::native_to_unicode($i)) != $i) { + print "not "; + } + print "ok "; + print $i + 1; + print "\n"; +} + +# Choose a largish number that might cause a seg fault if inappropriate array +# lookup +if (utf8::unicode_to_native(utf8::native_to_unicode(100000)) != 100000) { + print "not "; +} +print "ok "; +print "257\n"; |