File: Fold.t

package info (click to toggle)
libmime-ecoencode-perl 0.95-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 184 kB
  • sloc: perl: 2,122; makefile: 2; sh: 1
file content (162 lines) | stat: -rw-r--r-- 3,447 bytes parent folder | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/perl -w

# This script is written in utf8

use strict;
use warnings;

use Test::More tests => 14;
#use Test::More 'no_plan';
BEGIN { use_ok('MIME::EcoEncode::Fold') };

use Encode;
use MIME::EcoEncode::Fold;

my $in_utf8;
my $out_utf8;
my $in;
my $out;
my $str;

$in_utf8 =<<"END";

あああ00000aaaaaaあああ00000aaaaaaアアア00000aaあああ
アアア00000aaaaaaaあああ00000aaaaaaaあああ00000aaaaアア
00000aaaaaa00000aaaaaaaaa00000aaaaaaaaaaaaaaa00000
END


#
# test 2
#
$out_utf8 =<<"END";

あああ00000aaaaaaあああ0
0000aaaaaaアアア00000aaあ
ああ
アアア00000aaaaaaaあああ
00000aaaaaaaあああ00000aaa
aアア
00000aaaaaa00000aaaaaaaaa00000
aaaaaaaaaaaaaaa00000
END
$in = $in_utf8;
$out = $out_utf8;
is(mime_eco_fold($in, 'UTF-8', "\n", 30), $out,
   'UTF-8 "\n" 30');

#
# test 3
#
$out_utf8 =<<"END";

あああ00000aaaaaaあああ0
 0000aaaaaaアアア00000aa
 あああ
アアア00000aaaaaaaあああ
 00000aaaaaaaあああ00000aa
 aaアア
00000aaaaaa00000aaaaaaaaa00000
 aaaaaaaaaaaaaaa00000
END
$in = $in_utf8;
$out = $out_utf8;
is(mime_eco_fold($in, 'UTF-8', undef, 30), $out,
   'UTF-8 undef 30');

#
# test 4
#
$out_utf8 =<<"END";

あああ00000aaaaaa
あああ00000aaaaaaア
アア00000aaあああ
アアア00000aaaaaaaあ
ああ00000aaaaaaaあ
ああ00000aaaaアア
00000aaaaaa00000aaaaaaaaa00000
aaaaaaaaaaaaaaa00000
END
$in = encode('7bit-jis', decode_utf8($in_utf8));
$out = encode('7bit-jis', decode_utf8($out_utf8));
is(mime_eco_fold($in, 'ISO-2022-JP', "\n", 30), $out,
   'ISO-2022-JP "\n" 30');

#
# test 5
#
$out_utf8 =<<"END";

あああ00000aaaaaa
 あああ00000aaaaaa
 アアア00000aaあああ
アアア00000aaaaaaaあ
 ああ00000aaaaaaa
 あああ00000aaaaアア
00000aaaaaa00000aaaaaaaaa00000
 aaaaaaaaaaaaaaa00000
END
$in = encode('7bit-jis', decode_utf8($in_utf8));
$out = encode('7bit-jis', decode_utf8($out_utf8));
is(mime_eco_fold($in, 'ISO-2022-JP', undef, 30), $out,
   'ISO-2022-JP undef 30');


#
# test 6
#
$out_utf8 =<<"END";

あああ00000aaaaaaあああ00000aa
aaaaアアア00000aaあああ
アアア00000aaaaaaaあああ00000aaaa
aaaあああ00000aaaaアア
00000aaaaaa00000aaaaaaaaa00000
aaaaaaaaaaaaaaa00000
END
$in = encode('cp932', decode_utf8($in_utf8));
$out = encode('cp932', decode_utf8($out_utf8));
is(mime_eco_fold($in, 'Shift_JIS', "\n", 30), $out,
   'Shift_JIS "\n" 30');


#
# test 7
#
$out_utf8 =<<"END";

あああ00000aaaaaaあああ00000aa
 aaaaアアア00000aaあああ
アアア00000aaaaaaaあああ00000aaaa
 aaaあああ00000aaaaアア
00000aaaaaa00000aaaaaaaaa00000
 aaaaaaaaaaaaaaa00000
END
$in = encode('cp932', decode_utf8($in_utf8));
$out = encode('cp932', decode_utf8($out_utf8));
is(mime_eco_fold($in, 'Shift_JIS', undef, 30), $out,
   'Shift_JIS undef 30');


$str = " \n ";
is(mime_eco_fold($str, 'UTF-8', undef, 30), $str, 'SP + "\n" + SP');

$str = "";
is(mime_eco_fold($str, 'UTF-8', undef, 30), $str, 'zero length');

$str = undef;
is(mime_eco_fold($str, 'UTF-8', undef, 30), "", 'undef');

$str = "test0\x0d";
is(mime_eco_fold($str, 'UTF-8', undef, 30), $str, '\x0d');

$str = "test0\x0a";
is(mime_eco_fold($str, 'UTF-8', undef, 30), $str, '\x0a');

$str = "test0\x0d\x0a";
is(mime_eco_fold($str, 'UTF-8', undef, 30), $str, '\x0d\x0a');

$in = "00000aaaaaa00000aaaaaaaaa00000aaaaaaaaaaaaaaa00000";
$out = "00000aaaaaa00000aaaaaaaaa00000\n aaaaaaaaaaaaaaa00000";
is(mime_eco_fold($in, 'UTF-8', undef, 30), $out, 'ASCII');