root/branches/release-40/t/46-i18n-en.t @ 2562

Revision 2562, 1.7 kB (checked in by bchoate, 18 months ago)

Test suite cleanup. Use MT::Test to force t/ based configuration file for all tests. Fixed several tests that had incorrect expected values.

  • 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::Test;
26use MT::Util;
27my $mt = new MT;
28
29MT->set_language('en_US');
30require MT::I18N;
31
32is(MT::I18N::const('LENGTH_ENTRY_TITLE_FROM_TEXT'), 5);
33
34MT->config('PublishCharset', 'utf-8');
35my $utf8_str = 'IñtërnâtiÎnàlizÊtiÞn';
36is(length($utf8_str), 27); # make sure this is in bytes
37is(MT::I18N::substr_text('this is a test', 0, 4), 'this');
38is(MT::I18N::substr_text($utf8_str, 0, 4), 'Iñtë');
39is(MT::I18N::length_text($utf8_str), 20);
40is(MT::I18N::encode_text($utf8_str, undef, 'utf-8'), $utf8_str);
41is(MT::Util::dirify($utf8_str), "internationalizaetion");
42
43MT->config('PublishCharset', 'iso-8859-1');
44my $latin1_str = $utf8_str;
45Encode::from_to($latin1_str, 'utf-8', 'iso-8859-1');
46is(length($latin1_str), 20);
47is(MT::I18N::substr_text($latin1_str, 0, 4), substr($latin1_str, 0, 4));
48is(MT::I18N::length_text($latin1_str), 20);
49is(MT::I18N::encode_text($latin1_str, undef, 'utf-8'), $utf8_str);
50is(MT::I18N::convert_high_ascii($latin1_str), 'Internationalizaetion');
51
52MT->set_language('ja');
53MT->config('UseJcodeModule', 0);
54MT->config('PublishCharset', 'utf-8');
55
56$utf8_str = 'サむバヌショット、ネットりォヌクマンが圓たる';
57is(length($utf8_str), 66);
58is(MT::I18N::substr_text($utf8_str, 0, 4), 'サむバヌ');
59is(MT::I18N::length_text($utf8_str), 22);
60is(MT::I18N::encode_text($utf8_str, undef, 'utf-8'), $utf8_str);
Note: See TracBrowser for help on using the browser.