File: 02invalid.t

package info (click to toggle)
libtest-utf8-perl 1.00-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 208 kB
  • sloc: perl: 1,658; makefile: 2
file content (68 lines) | stat: -rw-r--r-- 1,314 bytes parent folder | download | duplicates (5)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 7;
use Test::Builder::Tester;
use Test::utf8;
use Encode;

####
# basic passing tests



test_out("ok 1 - valid string test");
is_valid_string("foo");
test_test("valid string");



test_out("ok 1 - fish");
is_valid_string("foo","fish");
test_test("valid string with name");



test_out("ok 1 - valid string test");
is_valid_string("\x{e9} is called e-acute");
test_test("string with latin-1");



test_out("ok 1 - valid string test");
is_valid_string("close the window with \x{2318}-w");
test_test("string with unicode only char");



test_out("ok 1 - valid string test");
my $empty_string = "";
Encode::_utf8_on($empty_string);
is_valid_string($empty_string);
test_test("empty string is valid string");



# create an invalid string
my $invalid = "this is an invalid char '\x{e9}' here";
Encode::_utf8_on($invalid);

test_out("not ok 1 - valid string test");
test_fail(+2);
test_diag("malformed byte sequence starting at byte 25");
is_valid_string($invalid);
test_test("invalid string test");



$invalid = "\x{e9}";
Encode::_utf8_on($invalid);

test_out("not ok 1 - valid string test");
test_fail(+2);
test_diag("malformed byte sequence starting at byte 0");
is_valid_string($invalid);
test_test("invalid string test starting with bad char");