github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/email/reply_test.go (about) 1 // Copyright 2017 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package email 5 6 import ( 7 "fmt" 8 "testing" 9 ) 10 11 func TestFormReply(t *testing.T) { 12 for i, test := range formReplyTests { 13 t.Run(fmt.Sprint(i), func(t *testing.T) { 14 result := FormReply(test.email, test.reply) 15 if test.result != result { 16 t.Logf("expect:\n%s", test.result) 17 t.Logf("got:\n%s", result) 18 t.Fail() 19 } 20 }) 21 } 22 } 23 24 var formReplyTests = []struct { 25 email *Email 26 reply string 27 result string 28 }{ 29 { 30 email: &Email{ 31 Body: `line1 32 line2 33 #syz foo 34 line3 35 `}, 36 reply: "this is reply", 37 result: `> line1 38 > line2 39 > #syz foo 40 41 this is reply 42 43 > line3 44 `, 45 }, 46 { 47 email: &Email{ 48 Body: ` 49 #syz-fix 50 line2 51 `}, 52 reply: "this is reply", 53 result: `> 54 > #syz-fix 55 56 this is reply 57 58 > line2 59 `, 60 }, 61 { 62 email: &Email{ 63 Body: ` 64 #syz: fix 65 line2 66 `}, 67 reply: "this is reply", 68 result: `> 69 > #syz: fix 70 71 this is reply 72 73 > line2 74 `, 75 }, 76 { 77 email: &Email{ 78 Body: `> line1 79 > line2 80 #syz foo 81 line3 82 `}, 83 reply: "this is reply\n", 84 result: `>> line1 85 >> line2 86 > #syz foo 87 88 this is reply 89 90 > line3 91 `, 92 }, 93 { 94 email: &Email{ 95 Body: `line1 96 line2 97 #syz foo`}, 98 reply: "this is reply 1\nthis is reply 2", 99 result: `> line1 100 > line2 101 > #syz foo 102 103 this is reply 1 104 this is reply 2 105 106 `, 107 }, 108 { 109 email: &Email{ 110 Body: `line1 111 line2 112 `}, 113 reply: "this is reply", 114 result: `> line1 115 > line2 116 117 this is reply 118 119 `, 120 }, 121 { 122 email: &Email{ 123 Body: `line1 124 #syz foo 125 line2 126 #syz bar`, 127 Commands: []*SingleCommand{ 128 {}, 129 {}, 130 }, 131 }, 132 reply: "this is reply 1\nthis is reply 2", 133 result: `> line1 134 > #syz foo 135 > line2 136 > #syz bar 137 138 this is reply 1 139 this is reply 2 140 141 `, 142 }, 143 }