forked from domodwyer/mailyak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplitter_test.go
224 lines (212 loc) · 14.2 KB
/
splitter_test.go
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
package mailyak
import (
"bufio"
"bytes"
"encoding/base64"
"testing"
)
// TestLineSplitterWrite ensures various length data is correctly broken up
func TestLineSplitterWrite(t *testing.T) {
t.Parallel()
tests := []struct {
name string
// Parameters.
p []byte
// Expected results.
want string
}{
{
"test_archive.zip",
[]byte{0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x09, 0x00, 0x08, 0x00, 0x66, 0x6d, 0xcf, 0x48, 0xb4, 0xf8,
0x71, 0xdd, 0x53, 0x01, 0x00, 0x00, 0xd0, 0x01, 0x00, 0x00, 0x2d, 0x00, 0x1c, 0x00, 0x64, 0x65,
0x61, 0x6c, 0x5f, 0x36, 0x39, 0x30, 0x30, 0x32, 0x34, 0x5f, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30,
0x36, 0x2d, 0x31, 0x35, 0x2d, 0x31, 0x33, 0x34, 0x33, 0x5f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74,
0x5f, 0x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 0x39, 0x80, 0xf5, 0xb2, 0x4b, 0x6d, 0xdb, 0x50, 0x4b, 0x07, 0x08, 0xb4, 0xf8,
0x71, 0xdd, 0x53, 0x01, 0x00, 0x00, 0xd0, 0x01, 0x00, 0x00, 0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03,
0x14, 0x00, 0x09, 0x00, 0x08, 0x00, 0x66, 0x6d, 0xcf, 0x48, 0xb4, 0xf8, 0x71, 0xdd, 0x53, 0x01,
0x00, 0x00, 0xd0, 0x01, 0x00, 0x00, 0x2d, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0xb4, 0x81, 0x00, 0x00, 0x00, 0x00, 0x64, 0x65, 0x61, 0x6c, 0x5f, 0x36, 0x39, 0x30,
0x30, 0x32, 0x34, 0x5f, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x31, 0x35, 0x2d, 0x31,
0x33, 0x34, 0x33, 0x5f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x6f, 0x72, 0x64, 0x65, 0x72,
0x73, 0x2e, 0x63, 0x73, 0x76, 0x55, 0x54, 0x05, 0x00, 0x03, 0x5f, 0x4d, 0x61, 0x57, 0x75, 0x78,
0x0b, 0x00, 0x01, 0x04, 0xe8, 0x03, 0x00, 0x00, 0x04, 0xe8, 0x03, 0x00, 0x00, 0x50, 0x4b, 0x05,
0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x73, 0x00, 0x00, 0x00, 0xca, 0x01, 0x00,
0x00, 0x00, 0x00,
},
"UEsDBBQACQAIAGZtz0i0+HHdUwEAANABAAAtABwAZGVhbF82OTAwMjRfMjAx\r\n" +
"Ni0wNi0xNS0xMzQzX2xhdGVzdF9vcmRlcnMuY3N2VVQJAANfTWFXXk1hV3V4\r\n" +
"CwABBOgDAAAE6AMAAM7PPgk5LEFORgHGXJbXelo896dK+mLtyDQU/2kTHLbi\r\n" +
"l5T5vks3UmJF4L/a11rp7uEvM54eyZlIgEsV9WFaIWbOXxxqu5Flow/rX8So\r\n" +
"n4IRHfKcnZQfvYAciqWArj9AUIhLW2d1xp5tI4TionlpYcQDGsTES/m+4V7h\r\n" +
"2LD1HsjWsDQih6xlpwpzcl4zdYHvfpHfBBeQ66n6kl60D+MKaIPHx3U6tLeB\r\n" +
"F18nruBbCpCtbozGAQq357r9HX8H4djmYTMiY+NwSdNwTREGBTLZXv1yZO9e\r\n" +
"+NSYpujhb4fVBZbzOmCHfpRpzWl/i467Leuhhi/pbYc2LuTg7Ghwjn4m13P3\r\n" +
"B7lcoAhRyVB8sO+tig09XWp9bFk2UwSqWy5jW9UABoS8bD71x1IdSMVhGmkv\r\n" +
"uoM04dqzP9YxidIQsrp+natL9zPFBl6RX6b74zi9OYD1sktt21BLBwi0+HHd\r\n" +
"UwEAANABAABQSwECHgMUAAkACABmbc9ItPhx3VMBAADQAQAALQAYAAAAAAAB\r\n" +
"AAAAtIEAAAAAZGVhbF82OTAwMjRfMjAxNi0wNi0xNS0xMzQzX2xhdGVzdF9v\r\n" +
"cmRlcnMuY3N2VVQFAANfTWFXdXgLAAEE6AMAAAToAwAAUEsFBgAAAAABAAEA\r\n" +
"cwAAAMoBAAAAAA==",
},
{
"test",
[]byte("test"),
"dGVzdA==",
},
{
"sentance",
[]byte("A man may fight for many things. His country, his principles, his friends. " +
"The glistening tear on the cheek of a golden child. But personally, I'd mud-wrestle " +
"my own mother for a ton of cash, an amusing clock and a sack of French porn."),
"QSBtYW4gbWF5IGZpZ2h0IGZvciBtYW55IHRoaW5ncy4gSGlzIGNvdW50cnks\r\n" +
"IGhpcyBwcmluY2lwbGVzLCBoaXMgZnJpZW5kcy4gVGhlIGdsaXN0ZW5pbmcg\r\n" +
"dGVhciBvbiB0aGUgY2hlZWsgb2YgYSBnb2xkZW4gY2hpbGQuIEJ1dCBwZXJz\r\n" +
"b25hbGx5LCBJJ2QgbXVkLXdyZXN0bGUgbXkgb3duIG1vdGhlciBmb3IgYSB0\r\n" +
"b24gb2YgY2FzaCwgYW4gYW11c2luZyBjbG9jayBhbmQgYSBzYWNrIG9mIEZy\r\n" +
"ZW5jaCBwb3JuLg==",
},
{
"test.png",
[]byte{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x01, 0x2c, 0x08, 0x02, 0x00, 0x00, 0x00, 0xf6, 0x1f, 0x19,
0x22, 0x00, 0x00, 0x03, 0x97, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0xed, 0xd9, 0x31, 0x8a, 0xc3,
0x40, 0x14, 0x44, 0xc1, 0x1e, 0xe3, 0xfb, 0x5f, 0x59, 0x8a, 0x9d, 0x09, 0x1c, 0xbc, 0x40, 0x55,
0x6c, 0xb4, 0x20, 0x70, 0xf2, 0x68, 0x98, 0x7f, 0xb6, 0x6b, 0xbb, 0xce, 0xef, 0xdf, 0xb6, 0xf3,
0xe8, 0x9f, 0xf3, 0xad, 0x6f, 0x7d, 0xfb, 0xe7, 0xb7, 0x9f, 0x01, 0xa9, 0xef, 0x4e, 0xfd, 0x13,
0xe0, 0xdd, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0xbc, 0x8e, 0x42,
0xcc, 0x12, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84,
0x10, 0x73, 0xa2, 0x80, 0x98, 0x25, 0x84, 0x98, 0x08, 0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62,
0x22, 0x84, 0x98, 0x08, 0x21, 0xe6, 0x44, 0x01, 0x31, 0x4b, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84,
0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0xaf, 0xa3, 0x10, 0xb3, 0x84, 0x10, 0x13, 0x21, 0xc4,
0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x9c, 0x28, 0x20, 0x66, 0x09,
0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08, 0x21, 0x26, 0x42, 0x88, 0x39,
0x51, 0x40, 0xcc, 0x12, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42,
0xcc, 0xeb, 0x28, 0xc4, 0x2c, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13,
0x21, 0xc4, 0x44, 0x08, 0x31, 0x27, 0x0a, 0x88, 0x59, 0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84,
0x98, 0x08, 0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62, 0x4e, 0x14, 0x10, 0xb3, 0x84, 0x10, 0x13,
0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0xf3, 0x3a, 0x0a, 0x31, 0x4b, 0x08,
0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0xcc, 0x89,
0x02, 0x62, 0x96, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08, 0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62,
0x22, 0x84, 0x98, 0x13, 0x05, 0xc4, 0x2c, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84,
0x10, 0x13, 0x21, 0xc4, 0xbc, 0x8e, 0x42, 0xcc, 0x12, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4,
0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x73, 0xa2, 0x80, 0x98, 0x25, 0x84, 0x98, 0x08,
0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08, 0x21, 0xe6, 0x44, 0x01, 0x31,
0x4b, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0xaf, 0xa3,
0x10, 0xb3, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13,
0x21, 0xc4, 0x9c, 0x28, 0x20, 0x66, 0x09, 0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84,
0x98, 0x08, 0x21, 0x26, 0x42, 0x88, 0x39, 0x51, 0x40, 0xcc, 0x12, 0x42, 0x4c, 0x84, 0x10, 0x13,
0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0xcc, 0xeb, 0x28, 0xc4, 0x2c, 0x21, 0xc4, 0x44, 0x08,
0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x27, 0x0a, 0x88, 0x59,
0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08, 0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62,
0x4e, 0x14, 0x10, 0xb3, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84,
0x10, 0xf3, 0x3a, 0x0a, 0x31, 0x4b, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4,
0x44, 0x08, 0x31, 0x11, 0x42, 0xcc, 0x89, 0x02, 0x62, 0x96, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08,
0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84, 0x98, 0x13, 0x05, 0xc4, 0x2c, 0x21, 0xc4,
0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0xbc, 0x8e, 0x42, 0xcc, 0x12,
0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x73,
0xa2, 0x80, 0x98, 0x25, 0x84, 0x98, 0x08, 0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84,
0x98, 0x08, 0x21, 0xe6, 0x44, 0x01, 0x31, 0x4b, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13,
0x21, 0xc4, 0x44, 0x08, 0x31, 0xaf, 0xa3, 0x10, 0xb3, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08,
0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x9c, 0x28, 0x20, 0x66, 0x09, 0x21, 0x26,
0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08, 0x21, 0x26, 0x42, 0x88, 0x39, 0x51, 0x40,
0xcc, 0x12, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0xcc, 0xeb,
0x28, 0xc4, 0x2c, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4,
0x44, 0x08, 0x31, 0x27, 0x0a, 0x88, 0x59, 0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08,
0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62, 0x4e, 0x14, 0x10, 0xb3, 0x84, 0x10, 0x13, 0x21, 0xc4,
0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0xf3, 0x3a, 0x0a, 0x31, 0x4b, 0x08, 0x31, 0x11,
0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0xcc, 0x89, 0x02, 0x62,
0x96, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08, 0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84,
0x98, 0x13, 0x05, 0xc4, 0x2c, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13,
0x21, 0xc4, 0xbc, 0x8e, 0x42, 0xcc, 0x12, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08,
0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x73, 0xa2, 0x80, 0x98, 0x25, 0x84, 0x98, 0x08, 0x21, 0x26,
0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08, 0x21, 0xe6, 0x44, 0x01, 0x31, 0x4b, 0x08,
0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0xaf, 0xa3, 0x10, 0xb3,
0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4,
0x9c, 0x28, 0x20, 0x66, 0x09, 0x21, 0x26, 0x42, 0x88, 0x89, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08,
0x21, 0x26, 0x42, 0x88, 0x39, 0x51, 0x40, 0xcc, 0x12, 0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4,
0x44, 0x08, 0x31, 0x11, 0x42, 0xcc, 0xeb, 0x28, 0xc4, 0x2c, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x11,
0x42, 0x4c, 0x84, 0x10, 0x13, 0x21, 0xc4, 0x44, 0x08, 0x31, 0x27, 0x0a, 0x88, 0x59, 0x42, 0x88,
0x89, 0x10, 0x62, 0x22, 0x84, 0x98, 0x08, 0x21, 0x26, 0x42, 0x88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EBMhxJwoIGYJISZCiIkQYiKEmAghJkKIOVFAzBJC\r\n" +
"TIQQEyHERAgxEULM6yjELCHERAgxEUJMhBATIcRECDEnCohZQoiJEGIihJgI\r\n" +
"ISZCiIkQYk4UELOEEBMhxEQIMRFCTIQQ8zoKMUsIMRFCTIQQEyHERAgxEULM\r\n" +
"iQJilhBiIoSYCCEmQoiJEGIihJgTBcQsIcRECDERQkyEEBMhxLyOQswSQkyE\r\n" +
"EBMhxEQIMRFCTIQQc6KAmCWEmAghJkKIiRBiIoSYCCHmRAExSwgxEUJMhBAT\r\n" +
"IcRECDGvoxCzhBATIcRECDERQkyEEBMhxJwoIGYJISZCiIkQYiKEmAghJkKI\r\n" +
"OVFAzBJCTIQQEyHERAgxEULM6yjELCHERAgxEUJMhBATIcRECDEnCohZQoiJ\r\n" +
"EGIihJgIISZCiN0HtAVfIctU0QAAAABJRU5ErkJggg==",
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var buf bytes.Buffer
w := &lineSplitter{w: &buf, maxLen: maxLineLen}
encoder := base64.NewEncoder(base64.StdEncoding, w)
_, err := encoder.Write(tt.p)
encoder.Close()
if err != nil {
t.Fatalf("%q. base64LineWriter.Write() error = %v", tt.name, err)
}
if buf.String() != tt.want {
t.Errorf("%q. base64LineWriter.Write() = \n%v\n, want \n%v\n", tt.name, buf.String(), tt.want)
}
})
}
}
func TestChunkedWrites(t *testing.T) {
s := "a 21 character string"
var buf bytes.Buffer
w := &lineSplitter{w: &buf, maxLen: maxLineLen}
for i := 0; i < 20; i++ {
if n, err := w.Write([]byte(s)); n != len(s) || err != nil {
t.Fatalf("wrote %d, err %v", n, err)
}
}
scanner := bufio.NewScanner(&buf)
for scanner.Scan() {
if len(scanner.Text()) > maxLineLen {
t.Errorf("got linelength = %d want <= %d\n", len(scanner.Text()), maxLineLen)
}
}
}