2013-04-28 21:45:00 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"github.com/bmizerany/assert"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2013-05-24 08:32:52 +04:00
|
|
|
func TestReadTitleAndBody(t *testing.T) {
|
2013-04-28 21:45:00 +04:00
|
|
|
message := `A title
|
|
|
|
A title continues
|
|
|
|
|
|
|
|
A body
|
|
|
|
A body continues
|
|
|
|
# comment
|
|
|
|
`
|
|
|
|
r := strings.NewReader(message)
|
|
|
|
reader := bufio.NewReader(r)
|
2013-05-28 23:42:11 +04:00
|
|
|
title, body, err := readTitleAndBodyFrom(reader)
|
2013-04-28 21:45:00 +04:00
|
|
|
assert.Equal(t, nil, err)
|
|
|
|
assert.Equal(t, "A title A title continues", title)
|
|
|
|
assert.Equal(t, "A body\nA body continues", body)
|
|
|
|
}
|