2017-07-02 14:08:04 +00:00
|
|
|
// Copyright 2017 syzkaller project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package email
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFormReply(t *testing.T) {
|
|
|
|
for i, test := range formReplyTests {
|
|
|
|
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
|
|
|
result := FormReply(test.email, test.reply)
|
|
|
|
if test.result != result {
|
|
|
|
t.Logf("expect:\n%s", test.result)
|
|
|
|
t.Logf("got:\n%s", result)
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var formReplyTests = []struct {
|
|
|
|
email string
|
|
|
|
reply string
|
|
|
|
result string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
email: `line1
|
|
|
|
line2
|
2017-08-17 17:09:07 +00:00
|
|
|
#syz foo
|
2017-07-02 14:08:04 +00:00
|
|
|
line3
|
|
|
|
`,
|
|
|
|
reply: "this is reply",
|
|
|
|
result: `> line1
|
|
|
|
> line2
|
2017-08-17 17:09:07 +00:00
|
|
|
> #syz foo
|
2017-07-02 14:08:04 +00:00
|
|
|
|
|
|
|
this is reply
|
|
|
|
|
|
|
|
> line3
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
email: `> line1
|
|
|
|
> line2
|
2017-08-17 17:09:07 +00:00
|
|
|
#syz foo
|
2017-07-02 14:08:04 +00:00
|
|
|
line3
|
|
|
|
`,
|
|
|
|
reply: "this is reply\n",
|
|
|
|
result: `>> line1
|
|
|
|
>> line2
|
2017-08-17 17:09:07 +00:00
|
|
|
> #syz foo
|
2017-07-02 14:08:04 +00:00
|
|
|
|
|
|
|
this is reply
|
|
|
|
|
|
|
|
> line3
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
email: `line1
|
|
|
|
line2
|
2017-08-17 17:09:07 +00:00
|
|
|
#syz foo`,
|
2017-07-02 14:08:04 +00:00
|
|
|
reply: "this is reply 1\nthis is reply 2",
|
|
|
|
result: `> line1
|
|
|
|
> line2
|
2017-08-17 17:09:07 +00:00
|
|
|
> #syz foo
|
2017-07-02 14:08:04 +00:00
|
|
|
|
|
|
|
this is reply 1
|
|
|
|
this is reply 2
|
|
|
|
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
email: `line1
|
|
|
|
line2
|
|
|
|
`,
|
|
|
|
reply: "this is reply",
|
|
|
|
result: `> line1
|
|
|
|
> line2
|
|
|
|
|
|
|
|
this is reply
|
|
|
|
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
}
|