-
Notifications
You must be signed in to change notification settings - Fork 34
/
tcplistener_test.go
35 lines (32 loc) · 1.07 KB
/
tcplistener_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package buffstreams
import (
"strconv"
"testing"
)
func TestListenTCPUsesDefaultMessageSize(t *testing.T) {
cfg := TCPListenerConfig{
Address: FormatAddress("", strconv.Itoa(5031)),
Callback: func([]byte) error { return nil },
}
buffM, err := ListenTCP(cfg)
if err != nil {
t.Errorf("Could not Listen on port %d: %s", cfg.MaxMessageSize, err.Error())
}
if buffM.connConfig.MaxMessageSize != DefaultMaxMessageSize {
t.Errorf("Expected Max Message Size to be %d, actually got %d", DefaultMaxMessageSize, buffM.connConfig.MaxMessageSize)
}
}
func TestListenTCPUsesSpecifiedMaxMessageSize(t *testing.T) {
cfg := TCPListenerConfig{
MaxMessageSize: 8196,
Address: FormatAddress("", strconv.Itoa(5032)),
Callback: func([]byte) error { return nil },
}
buffM, err := ListenTCP(cfg)
if err != nil {
t.Errorf("Could not Listen on port %d: %s", cfg.MaxMessageSize, err.Error())
}
if buffM.connConfig.MaxMessageSize != cfg.MaxMessageSize {
t.Errorf("Expected Max Message Size to be %d, actually got %d", cfg.MaxMessageSize, buffM.connConfig.MaxMessageSize)
}
}