30 lines
786 B
Go
30 lines
786 B
Go
package app
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestInputWritePiecesOnlySplitAgentEnters(t *testing.T) {
|
|
in := []byte("alpha\nbeta\rgamma")
|
|
for _, kind := range []ChildKind{KindTerminal, KindCommand} {
|
|
t.Run(string(kind), func(t *testing.T) {
|
|
got := inputWritePieces(kind, in)
|
|
if len(got) != 1 || !bytes.Equal(got[0], in) {
|
|
t.Fatalf("inputWritePieces(%s) = %#v, want one original chunk", kind, got)
|
|
}
|
|
})
|
|
}
|
|
|
|
got := inputWritePieces(KindAgent, in)
|
|
if len(got) != 5 {
|
|
t.Fatalf("agent pieces len = %d, want 5 (%#v)", len(got), got)
|
|
}
|
|
want := [][]byte{[]byte("alpha"), []byte("\n"), []byte("beta"), []byte("\r"), []byte("gamma")}
|
|
for i := range want {
|
|
if !bytes.Equal(got[i], want[i]) {
|
|
t.Fatalf("agent piece %d = %q, want %q", i, got[i], want[i])
|
|
}
|
|
}
|
|
}
|