diff --git a/client/commands.go b/client/commands.go index 164e04e..810c944 100644 --- a/client/commands.go +++ b/client/commands.go @@ -64,13 +64,13 @@ func indexFragment(s string) int { // 3. splitLen itself func splitMessage(msg string, splitLen int) (msgs []string) { // This is quite short ;-) - if splitLen < 10 { - splitLen = 10 + if splitLen < 13 { + splitLen = 13 } for len(msg) > splitLen { - idx := indexFragment(msg[:splitLen]) + idx := indexFragment(msg[:splitLen-3]) if idx < 0 { - idx = splitLen + idx = splitLen - 3 } msgs = append(msgs, msg[:idx] + "...") msg = msg[idx:] diff --git a/client/commands_test.go b/client/commands_test.go index a4d457e..e6800dc 100644 --- a/client/commands_test.go +++ b/client/commands_test.go @@ -60,12 +60,12 @@ func TestSplitMessage(t *testing.T) { {"", 0, []string{""}}, {"foo", 0, []string{"foo"}}, {"foo bar baz beep", 0, []string{"foo bar ...", "baz beep"}}, - {"foo bar baz beep", 13, []string{"foo bar baz ...", "beep"}}, - {"foo. bar baz beep", 0, []string{"foo. ...", "bar baz ...", "beep"}}, - {"foo bar, baz beep", 13, []string{"foo bar, ...", "baz beep"}}, + {"foo bar baz beep", 15, []string{"foo bar baz ...", "beep"}}, + {"foo. bar baz, beep.", 0, []string{"foo. ...", "bar baz, ...", "beep."}}, + {"foo bar, baz beep", 15, []string{"foo bar, ...", "baz beep"}}, {"0123456789012345", 0, []string{"0123456789...", "012345"}}, - {"0123456789012345", 13, []string{"0123456789012...", "345"}}, - {"0123456789012345", 20, []string{"0123456789012345"}}, + {"0123456789012345", 15, []string{"012345678901...", "2345"}}, + {"0123456789012345", 16, []string{"0123456789012345"}}, } for i, test := range tests { out := splitMessage(test.in, test.sp) @@ -81,7 +81,7 @@ func TestClientCommands(t *testing.T) { // Avoid having to type ridiculously long lines to test that // messages longer than SplitLen are correctly sent to the server. - c.cfg.SplitLen = 20 + c.cfg.SplitLen = 23 c.Pass("password") s.nc.Expect("PASS password")