root/branches/boomer/t/46-i18n-en.t @ 1098

Revision 1098, 1.7 kB (checked in by hachi, 2 years ago)

Branching for boomer from release-19, rev 62318

  • Property svn:keywords set to Id Revision
Line 
1# test suite for MT::I18N modules
2
3# english / utf-8
4# english / latin-1
5# french / utf-8
6# french / latin-1
7# japanese / utf-8
8# japanese / shift_jis
9# japanese / euc
10
11# routines to test
12#     substr_text
13#     length_text
14#     wrap_text
15#     break_up_text
16#     first_n_text
17#     convert_high_ascii
18#     const
19
20use lib 't/lib', 'extlib', 'lib', '../lib', '../extlib';
21use Test::More tests => 16;
22
23use Encode;
24use MT;
25use MT::Util;
26my $mt = new MT;
27
28MT->set_language('en_US');
29require MT::I18N;
30
31is(MT::I18N::const('LENGTH_ENTRY_TITLE_FROM_TEXT'), 5);
32
33MT->config('PublishCharset', 'utf-8');
34my $utf8_str = 'IñtërnâtiÎnàlizÊtiÞn';
35is(length($utf8_str), 27); # make sure this is in bytes
36is(MT::I18N::substr_text('this is a test', 0, 4), 'this');
37is(MT::I18N::substr_text($utf8_str, 0, 4), 'Iñtë');
38is(MT::I18N::length_text($utf8_str), 20);
39is(MT::I18N::encode_text($utf8_str, undef, 'utf-8'), $utf8_str);
40is(MT::Util::dirify($utf8_str), "internationalizaetion");
41
42MT->config('PublishCharset', 'iso-8859-1');
43my $latin1_str = $utf8_str;
44Encode::from_to($latin1_str, 'utf-8', 'iso-8859-1');
45is(length($latin1_str), 20);
46is(MT::I18N::substr_text($latin1_str, 0, 4), substr($latin1_str, 0, 4));
47is(MT::I18N::length_text($latin1_str), 20);
48is(MT::I18N::encode_text($latin1_str, undef, 'utf-8'), $utf8_str);
49is(MT::I18N::convert_high_ascii($latin1_str), 'Internationalizaetion');
50
51MT->set_language('ja');
52MT->config('UseJcodeModule', 0);
53MT->config('PublishCharset', 'utf-8');
54
55$utf8_str = 'サむバヌショット、ネットりォヌクマンが圓たる';
56is(length($utf8_str), 66);
57is(MT::I18N::substr_text($utf8_str, 0, 4), 'サむバヌ');
58is(MT::I18N::length_text($utf8_str), 22);
59is(MT::I18N::encode_text($utf8_str, undef, 'utf-8'), $utf8_str);
Note: See TracBrowser for help on using the browser.