summaryrefslogtreecommitdiff
path: root/ext/XS-APItest/t/utf8.t
diff options
context:
space:
mode:
Diffstat (limited to 'ext/XS-APItest/t/utf8.t')
-rw-r--r--ext/XS-APItest/t/utf8.t50
1 files changed, 50 insertions, 0 deletions
diff --git a/ext/XS-APItest/t/utf8.t b/ext/XS-APItest/t/utf8.t
index acba778067..6619ecadce 100644
--- a/ext/XS-APItest/t/utf8.t
+++ b/ext/XS-APItest/t/utf8.t
@@ -423,9 +423,11 @@ for my $u (sort { utf8::unicode_to_native($a) <=> utf8::unicode_to_native($b) }
}
my $valid_under_strict = 1;
+ my $valid_under_c9strict = 1;
if ($n > 0x10FFFF) {
$this_utf8_flags &= ~($UTF8_DISALLOW_SUPER|$UTF8_WARN_SUPER);
$valid_under_strict = 0;
+ $valid_under_c9strict = 0;
}
elsif (($n & 0xFFFE) == 0xFFFE) {
$this_utf8_flags &= ~($UTF8_DISALLOW_NONCHAR|$UTF8_WARN_NONCHAR);
@@ -491,6 +493,27 @@ for my $u (sort { utf8::unicode_to_native($a) <=> utf8::unicode_to_native($b) }
diag "The warnings were: " . join(", ", @warnings);
}
+ $ret = test_isC9_STRICT_UTF8_CHAR($bytes, $len);
+ $expected_len = ($valid_under_c9strict) ? $len : 0;
+ is($ret, $expected_len, "Verify isC9_STRICT_UTF8_CHAR($display_bytes) returns expected length: $len");
+
+ unless (is(scalar @warnings, 0,
+ "Verify isC9_STRICT_UTF8_CHAR() for $hex_n generated no warnings"))
+ {
+ diag "The warnings were: " . join(", ", @warnings);
+ }
+
+ undef @warnings;
+
+ $ret = test_isC9_STRICT_UTF8_CHAR($bytes, $len - 1);
+ is($ret, 0, "Verify isC9_STRICT_UTF8_CHAR() with too short length parameter returns 0");
+
+ unless (is(scalar @warnings, 0,
+ "Verify isC9_STRICT_UTF8_CHAR() generated no warnings"))
+ {
+ diag "The warnings were: " . join(", ", @warnings);
+ }
+
undef @warnings;
$ret_ref = test_valid_utf8_to_uvchr($bytes);
@@ -769,6 +792,14 @@ foreach my $test (@malformations) {
diag "The warnings were: " . join(", ", @warnings);
}
+ $ret = test_isC9_STRICT_UTF8_CHAR($bytes, $length);
+ is($ret, 0, "$testname: isC9_STRICT_UTF8_CHAR returns 0");
+ unless (is(scalar @warnings, 0,
+ "$testname: isC9_STRICT_UTF8_CHAR() generated no warnings"))
+ {
+ diag "The warnings were: " . join(", ", @warnings);
+ }
+
for my $j (1 .. $length - 1) {
my $partial = substr($bytes, 0, $j);
@@ -1294,6 +1325,25 @@ foreach my $test (@tests) {
diag "The warnings were: " . join(", ", @warnings);
}
+ undef @warnings;
+ $ret = test_isC9_STRICT_UTF8_CHAR($bytes, $length);
+ if ($will_overflow) {
+ is($ret, 0, "isC9_STRICT_UTF8_CHAR() $testname: returns 0");
+ }
+ else {
+ my $expected_ret = ( $testname =~ /surrogate/
+ || $allowed_uv > 0x10FFFF)
+ ? 0
+ : $length;
+ is($ret, $expected_ret,
+ "isC9_STRICT_UTF8_CHAR() $testname: returns expected length: $expected_ret");
+ }
+ unless (is(scalar @warnings, 0,
+ "isC9_STRICT_UTF8_CHAR() $testname: generated no warnings"))
+ {
+ diag "The warnings were: " . join(", ", @warnings);
+ }
+
# Test partial character handling, for each byte not a full character
for my $j (1.. $length - 1) {