2 use C4::Interface::CGI::Output;
5 use vars qw( $loaded );
10 'Normal HTML without meta tag',
11 sub { guesscharset($_[0]) },
14 <title>control case</title>
17 'Result of guesscharset with normal HTML with irrelevant meta tag',
18 sub { guesscharset($_[0]) },
21 <meta http-equiv="Content-Language" content="zh-TW">
24 'Result of guesstype with normal HTML with irrelevant meta tag',
25 sub { guesstype($_[0]) },
28 <meta http-equiv="Content-Language" content="zh-TW">
31 'Result of guesscharset with normal HTML with relevant meta tag',
32 sub { guesscharset($_[0]) },
35 <meta http-equiv="Content-Type" content="text/html; charset=big5">
38 'Result of guesstype with normal HTML with relevant meta tag',
39 sub { guesstype($_[0]) },
40 'text/html; charset=big5',
42 <meta http-equiv="Content-Type" content="text/html; charset=big5">
45 'Variant 1 using single quotes',
46 sub { guesstype($_[0]) },
47 'text/html; charset=iso-2022-jp',
49 <meta http-equiv="Content-Type" content='text/html; charset=iso-2022-jp'>
52 'Variant 2 using single quotes',
53 sub { guesstype($_[0]) },
54 'text/html; charset=utf-8',
56 <meta http-equiv='Content-Type' content="text/html; charset=utf-8">
59 'Unquoted Content-Type',
60 sub { guesstype($_[0]) },
61 'text/html; charset=big5',
63 <meta http-equiv=Content-Type content="text/html; charset=big5">
67 sub { guesstype($_[0]) },
68 'text/html; charset=iso-8859-2',
70 <meta http-equiv=Content-Type content="text/html; charset=iso-8859-2" />
73 'Expected attributes in reverse order',
74 sub { guesstype($_[0]) },
75 'text/html; charset=big5',
77 <meta content="text/html; charset=big5" http-equiv="Content-Type">
80 'Extra whitespace at end',
81 sub { guesstype($_[0]) },
82 'text/html; charset=big5',
84 <meta http-equiv="Content-Type" content="text/html; charset=big5" >
88 sub { guesstype($_[0]) },
89 'text/html; charset=big5',
92 http-equiv="Content-Type"
93 content="text/html; charset=big5"
97 # FIXME - THIS IS NOT A WELL-WRITTEN TEST CASE!!!
98 'With surrounding HTML',
99 sub { guesstype($_[0]) },
100 'text/html; charset=us-ascii',
104 <title>Test case with surrounding HTML</title>
105 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
108 The return value should not be contaiminated with any surround HTML
109 FIXME: Auth.pm returns in code that can contaminate the charset
110 FIXME: if we do not explicitly disallow whitespace in the charset
118 BEGIN { $| = 1; printf "1..%d\n", scalar(@tests); }
119 END {print "not ok 1\n" unless $loaded;}
123 # Run all tests in sequence
124 for (my $i = 1; $i <= scalar @tests; $i += 1) {
125 my $test = $tests[$i - 1];
126 my($title, $f, $expected, $input) = @$test;
127 die "not ok $i (malformed test case)\n"
128 unless @$test == 4 && ref $f eq 'CODE';
130 my $output = &$f($input);
132 (!defined $output && !defined $expected)
133 || (defined $output && defined $expected && $output eq $expected)
135 print "ok $i - $title\n";
137 print "not ok $i - $title: got ",
138 (defined $output? "\"$output\"": 'undef'),
140 (defined $expected? "\"$expected\"": 'undef'),