diff options
| author | Paul Buetow <paul@buetow.org> | 2023-06-18 13:42:51 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-06-18 13:42:51 +0300 |
| commit | 5f24c3a2ce346a31820ae27676f18a4d71899a34 (patch) | |
| tree | 7a7c92d1f9cd0b9f01b8964ea9015d9bd2485cd9 /internal | |
| parent | 93b3e63e89594b2b7a05b791a5cfc366f10c763b (diff) | |
rename
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/tcp/tcp_test.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/internal/tcp/tcp_test.go b/internal/tcp/tcp_test.go index 9b4d61a..668758c 100644 --- a/internal/tcp/tcp_test.go +++ b/internal/tcp/tcp_test.go @@ -4,30 +4,30 @@ import ( "testing" ) -type readTest struct { +type readWriteTest struct { sizeWritten *bool sizeRead *bool sizeBytes []byte messageBytes []byte } -func (rt readTest) Write(b []byte) (n int, err error) { - if !*rt.sizeWritten { - copy(rt.sizeBytes, b) - *rt.sizeWritten = true +func (rwt readWriteTest) Write(b []byte) (n int, err error) { + if !*rwt.sizeWritten { + copy(rwt.sizeBytes, b) + *rwt.sizeWritten = true } else { - copy(rt.messageBytes, b) + copy(rwt.messageBytes, b) } return len(b), nil } -func (rt readTest) Read(b []byte) (n int, err error) { - if !*rt.sizeRead { - copy(b, rt.sizeBytes) - *rt.sizeRead = true +func (rwt readWriteTest) Read(b []byte) (n int, err error) { + if !*rwt.sizeRead { + copy(b, rwt.sizeBytes) + *rwt.sizeRead = true } else { - copy(b, rt.messageBytes) + copy(b, rwt.messageBytes) } return len(b), nil } @@ -40,18 +40,18 @@ func TestReadWrite(t *testing.T) { var sizeWritten bool var sizeRead bool - rt := readTest{ + rwt := readWriteTest{ sizeWritten: &sizeWritten, sizeRead: &sizeRead, sizeBytes: make([]byte, 8), messageBytes: make([]byte, len([]byte(message))), } - if err := WriteStr(rt, message); err != nil { + if err := WriteStr(rwt, message); err != nil { t.Errorf(err.Error()) } - response, err := ReadStr(rt) + response, err := ReadStr(rwt) if err != nil { t.Errorf(err.Error()) } |
