Skip to content

Commit

Permalink
Merge pull request #5 from kyokomi/bugfix-text-colons
Browse files Browse the repository at this point in the history
added the space check
  • Loading branch information
kyokomi committed Feb 25, 2016
2 parents 1c2f77e + fda82aa commit 1f5ed6f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"unicode"
)

//go:generate generateEmojiCodeMap -pkg emoji
Expand Down Expand Up @@ -38,8 +39,14 @@ func replaseEmoji(input *bytes.Buffer) string {
r = emoji.String()
break
}

emoji.WriteRune(i)

if unicode.IsSpace(i) {
r = emoji.String()
break
}

if i == ':' {
r = emojize(emoji.String())
break
Expand Down
17 changes: 15 additions & 2 deletions emoji_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@ const (
beerText = " ビール!!!"
)

var testFText = "test " + emojiCodeMap[beerKey] + ReplacePadding + beerText
var testText = emojiCodeMap[beerKey] + ReplacePadding + beerText
var testFText = "test " + emojize(beerKey) + beerText
var testText = emojize(beerKey) + beerText

func TestMultiColons(t *testing.T) {
var buf bytes.Buffer
_, err := Fprint(&buf, "A :smile: and another: :smile:")
if err != nil {
t.Error("Fprint ", err)
}

testCase := "A " + emojize(":smile:") + " and another: " + emojize(":smile:")
if buf.String() != testCase {
t.Error("Fprint ", buf.String(), "!=", testCase)
}
}

func TestCodeMap(t *testing.T) {
m := CodeMap()
Expand Down

0 comments on commit 1f5ed6f

Please sign in to comment.