fix index out of range bug.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-11-17 13:13:43 +08:00
parent 91ae3a4c55
commit 42457f46db
2 changed files with 5 additions and 1 deletions

View File

@ -141,7 +141,7 @@ func parseTo(to []string, authorEmail string, matchEmail bool) []int64 {
var ids []int64 var ids []int64
attachEmail := true attachEmail := true
for _, value := range to { for _, value := range trimElement(to) {
idArray := trimElement(strings.Split(value, ":")) idArray := trimElement(strings.Split(value, ":"))
// check id // check id

View File

@ -146,6 +146,10 @@ func TestParseTo(t *testing.T) {
ids = parseTo(input, "a@gmail.com", true) ids = parseTo(input, "a@gmail.com", true)
assert.Equal(t, []int64{0, 4, 5}, ids) assert.Equal(t, []int64{0, 4, 5}, ids)
// test empty ids
ids = parseTo([]string{"", " ", " "}, "a@gmail.com", true)
assert.Equal(t, 0, len(ids))
} }
func TestCheckFileExist(t *testing.T) { func TestCheckFileExist(t *testing.T) {