mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-20 16:45:56 +08:00
23 lines
367 B
Go
23 lines
367 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestCopySourceToDest(t *testing.T) {
|
|
const input = "foo"
|
|
source := strings.NewReader(input)
|
|
dest := bytes.NewBuffer(make([]byte, 0))
|
|
|
|
err := copySourceToDest(source, dest)
|
|
if err != nil {
|
|
t.FailNow()
|
|
}
|
|
|
|
got := dest.String()
|
|
if got != input {
|
|
t.Errorf("expected: %s, got: %s", input, got)
|
|
}
|
|
}
|