NewErrOnWriteCall(buf, 2) in := []string{"foo", "bar", "baz"} sep := "," exp := "foo" n, err := WriteJoined(w, in, sep) if n != len(exp) || !errors.Is(err, errOnWriteCall) { t.Errorf( "WriteJoined(...) = %d, %v: wanted %d, %v", n, err, len(exp), errOnWriteCall, ) } got := buf.String() if got != exp { t.Errorf( "unexpected bytes written (-exp, +got): %v", diff.LineDiff(exp, got).Join(), ) } }