summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-12-12 20:09:00 +0000
committerFather Chrysostomos <sprout@cpan.org>2011-07-12 21:46:51 -0700
commitc12735bbf21c427d9828557cda9e0c2ea60962c0 (patch)
treed433838bf5695b6d3b98bcb4f07885957106da28 /ext
parentcc76b5cc1552a60539ae1e99cc0b9817087d4bc4 (diff)
downloadperl-c12735bbf21c427d9828557cda9e0c2ea60962c0.tar.gz
API test for find_rundefsv()
Diffstat (limited to 'ext')
-rw-r--r--ext/XS-APItest/APItest.xs14
-rw-r--r--ext/XS-APItest/t/underscore_length.t20
2 files changed, 34 insertions, 0 deletions
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index 0b3a6cba3d..d3d7274fca 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -2861,6 +2861,20 @@ CODE:
OUTPUT:
RETVAL
+STRLEN
+underscore_length()
+PROTOTYPE:
+PREINIT:
+ SV *u;
+ U8 *pv;
+ STRLEN bytelen;
+CODE:
+ u = find_rundefsv();
+ pv = (U8*)SvPV(u, bytelen);
+ RETVAL = SvUTF8(u) ? utf8_length(pv, pv+bytelen) : bytelen;
+OUTPUT:
+ RETVAL
+
MODULE = XS::APItest PACKAGE = XS::APItest::Magic
PROTOTYPES: DISABLE
diff --git a/ext/XS-APItest/t/underscore_length.t b/ext/XS-APItest/t/underscore_length.t
new file mode 100644
index 0000000000..7ca6906322
--- /dev/null
+++ b/ext/XS-APItest/t/underscore_length.t
@@ -0,0 +1,20 @@
+use warnings;
+use strict;
+
+use Test::More tests => 4;
+
+use XS::APItest qw(underscore_length);
+
+$_ = "foo";
+is underscore_length(), 3;
+
+$_ = "snowman \x{2603}";
+is underscore_length(), 9;
+
+my $_ = "xyzzy";
+is underscore_length(), 5;
+
+$_ = "pile of poo \x{1f4a9}";
+is underscore_length(), 13;
+
+1;