-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathmodified_utf7_codec_test.dart
More file actions
66 lines (55 loc) · 1.75 KB
/
modified_utf7_codec_test.dart
File metadata and controls
66 lines (55 loc) · 1.75 KB
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
import 'dart:convert';
import 'package:enough_mail_plus/src/codecs/modified_utf7_codec.dart';
import 'package:test/test.dart';
void main() {
const codec = ModifiedUtf7Codec();
const encoding = utf8;
group('Modified UTF7 decoding', () {
test('Simple case 1', () {
const input = '&Jjo-!';
expect(codec.decodeText(input, encoding), '☺!');
});
test('Simple case 2', () {
const input = 'Hello, &ThZ1TA-';
expect(codec.decodeText(input, encoding), 'Hello, 世界');
});
test('Encoded Ampersand', () {
const input = 'hello&-goodbye';
expect(codec.decodeText(input, encoding), 'hello&goodbye');
});
test('English, Japanese, and Chinese', () {
const input = '~peter/mail/&ZeVnLIqe-/&U,BTFw-';
expect(codec.decodeText(input, encoding), '~peter/mail/日本語/台北');
});
});
group('Modified UTF7 encoding', () {
test('Simple case 1', () {
const input = '☺!';
expect(codec.encodeText(input), '&Jjo-!');
});
test('Simple case 2', () {
const input = 'Hello, 世界';
expect(codec.encodeText(input), 'Hello, &ThZ1TA-');
});
test('Encoded Ampersand', () {
const input = 'hello&goodbye';
expect(codec.encodeText(input), 'hello&-goodbye');
});
test('English, Japanese, and Chinese', () {
const input = '~peter/mail/日本語/台北';
expect(codec.encodeText(input), '~peter/mail/&ZeVnLIqe-/&U,BTFw-');
});
test('quotes', () {
const input = '""';
expect(codec.encodeText(input), '""');
});
test('* wildcard', () {
const input = '*';
expect(codec.encodeText(input), '*');
});
test('% wildcard', () {
const input = '%';
expect(codec.encodeText(input), '%');
});
});
}