OXIESEC PANEL
- Current Dir:
/
/
opt
/
golang
/
1.19.4
/
src
/
testing
/
iotest
Server IP: 2a02:4780:11:1084:0:327f:3464:10
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
12/01/2022 06:13:56 PM
rwxr-xr-x
📄
example_test.go
469 bytes
12/01/2022 06:13:01 PM
rw-r--r--
📄
logger.go
1.26 KB
12/01/2022 06:13:01 PM
rw-r--r--
📄
logger_test.go
3.42 KB
12/01/2022 06:13:01 PM
rw-r--r--
📄
reader.go
7.94 KB
12/01/2022 06:13:01 PM
rw-r--r--
📄
reader_test.go
6.14 KB
12/01/2022 06:13:01 PM
rw-r--r--
📄
writer.go
674 bytes
12/01/2022 06:13:01 PM
rw-r--r--
📄
writer_test.go
876 bytes
12/01/2022 06:13:01 PM
rw-r--r--
Editing: writer_test.go
Close
// Copyright 2019 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package iotest import ( "bytes" "testing" ) var truncateWriterTests = []struct { in string want string trunc int64 n int }{ {"hello", "", -1, 5}, {"world", "", 0, 5}, {"abcde", "abc", 3, 5}, {"edcba", "edcba", 7, 5}, } func TestTruncateWriter(t *testing.T) { for _, tt := range truncateWriterTests { buf := new(bytes.Buffer) tw := TruncateWriter(buf, tt.trunc) n, err := tw.Write([]byte(tt.in)) if err != nil { t.Errorf("Unexpected error %v for\n\t%+v", err, tt) } if g, w := buf.String(), tt.want; g != w { t.Errorf("got %q, expected %q", g, w) } if g, w := n, tt.n; g != w { t.Errorf("read %d bytes, but expected to have read %d bytes for\n\t%+v", g, w, tt) } } }