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
|
package mnemonicode_test
import (
"bytes"
"io"
"strings"
"testing"
"github.com/schollz/mnemonicode"
)
func TestIssue002(t *testing.T) {
buf := &bytes.Buffer{}
// Code from:
const issue = `https://bitbucket.org/dchapes/mnemonicode/issues/2`
config := mnemonicode.NewDefaultConfig()
config.GroupsPerLine = 1
config.LineSuffix = "\n"
config.GroupSeparator = "\n"
config.WordPadding = 0
config.WordsPerGroup = 1
config.WordSeparator = "\n"
src := strings.NewReader("abcdefgh")
r := mnemonicode.NewEncodeReader(src, config)
//io.Copy(os.Stdout, r)
io.Copy(buf, r)
// Note, in the issue the expected trailing newline is missing.
const expected = `bogart
atlas
safari
airport
cabaret
shock`
if s := buf.String(); s != expected {
t.Errorf("%v\n\tgave %q\n\twant%q", issue, s, expected)
}
}
|