| 1 | package bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.13 bytes/" |
| 5 | "crypto/randscip-go gomod github.com/golang/go/src go1.13 `crypto/rand`/" |
| 6 | "encoding/gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/" |
| 7 | "errorsscip-go gomod github.com/golang/go/src go1.13 errors/" |
| 8 | "ioscip-go gomod github.com/golang/go/src go1.13 io/" |
| 9 | "io/ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/" |
| 10 | "mathscip-go gomod github.com/golang/go/src go1.13 math/" |
| 11 | "osscip-go gomod github.com/golang/go/src go1.13 os/" |
| 12 | "testingscip-go gomod github.com/golang/go/src go1.13 testing/" |
| 13 | ) |
| 14 | |
| 15 | func BenchmarkMemoryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BenchmarkMemory().(b *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Bscip-go gomod github.com/golang/go/src go1.13 testing/B#) { |
| 16 | buf := Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(32 * 1024) |
| 17 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.13 testing/B#N.; i++ { |
| 18 | ioscip-go gomod github.com/golang/go/src go1.13 io/.Copyscip-go gomod github.com/golang/go/src go1.13 io/Copy().(buf, ioscip-go gomod github.com/golang/go/src go1.13 io/.LimitReaderscip-go gomod github.com/golang/go/src go1.13 io/LimitReader().(randscip-go gomod github.com/golang/go/src go1.13 `crypto/rand`/.Readerscip-go gomod github.com/golang/go/src go1.13 `crypto/rand`/Reader., 32*1024)) |
| 19 | ioscip-go gomod github.com/golang/go/src go1.13 io/.Copyscip-go gomod github.com/golang/go/src go1.13 io/Copy().(ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.Discardscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/Discard., buf) |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | func TestPoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestPool().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 24 | pool := NewPoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPool().(func() Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# { return Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) }) |
| 25 | buf, err := pool.Getscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Pool#Get.() |
| 26 | if err != nil { |
| 27 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 28 | } |
| 29 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello world")) |
| 30 | pool.Putscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Pool#Put.(buf) |
| 31 | } |
| 32 | |
| 33 | func TestMemPoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestMemPool().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 34 | p := NewMemPoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMemPool().(10) |
| 35 | poolTestscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/poolTest().(p, t) |
| 36 | |
| 37 | b := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(nil) |
| 38 | enc := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewEncoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewEncoder().(b) |
| 39 | if err := enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&p); err != nil { |
| 40 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 41 | } |
| 42 | |
| 43 | var pool Poolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Pool# |
| 44 | dec := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewDecoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewDecoder().(b) |
| 45 | if err := dec.Decodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Decoder#Decode().(&pool); err != nil { |
| 46 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 47 | } |
| 48 | poolTestscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/poolTest().(pool, t) |
| 49 | } |
| 50 | |
| 51 | func poolTestscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/poolTest().(pool Poolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Pool#, t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 52 | buf, err := pool.Getscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Pool#Get.() |
| 53 | if err != nil { |
| 54 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 55 | } |
| 56 | if n, err := buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello world")); n != 10 { |
| 57 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("wrote incorrect amount") |
| 58 | } else if err == nil { |
| 59 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("should have been a shortwrite error here") |
| 60 | } |
| 61 | pool.Putscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Pool#Put.(buf) |
| 62 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() > 0 { |
| 63 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("should have emptied the buffer") |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | func TestFilePoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestFilePool().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 68 | pool := NewFilePoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFilePool().(1024, "::~_bad_dir_~::") |
| 69 | buf := NewPartitionscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartition().(pool) |
| 70 | _, err := buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello")) |
| 71 | if err == nil { |
| 72 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("an error was expected here") |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func TestFilePool2scip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestFilePool2().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 77 | pool := NewFilePoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFilePool().(1024, "::~_bad_dir_~::") |
| 78 | buf := NewPartitionscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartition().(pool, Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(0)) |
| 79 | _, err := buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello")) |
| 80 | if err == nil { |
| 81 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("an error was expected here") |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | func TestOverflowscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestOverflow().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 86 | buf := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5), Discardscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Discard.) |
| 87 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("Hello World")) |
| 88 | |
| 89 | b := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(nil) |
| 90 | enc := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewEncoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewEncoder().(b) |
| 91 | if err := enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&buf); err != nil { |
| 92 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 93 | } |
| 94 | |
| 95 | var buf2 Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# |
| 96 | dec := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewDecoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewDecoder().(b) |
| 97 | if err := dec.Decodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Decoder#Decode().(&buf2); err != nil { |
| 98 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 99 | } |
| 100 | |
| 101 | buf = buf2 |
| 102 | |
| 103 | data, err := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(buf) |
| 104 | if err != nil { |
| 105 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 106 | } |
| 107 | |
| 108 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data, []byte("Hello")) { |
| 109 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Expected Hello got %s", string(data)) |
| 110 | } |
| 111 | |
| 112 | } |
| 113 | |
| 114 | func TestWriteAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestWriteAt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 115 | var b BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt# |
| 116 | |
| 117 | b = Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5) |
| 118 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 119 | |
| 120 | file, err := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.TempFilescip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/TempFile().("", "buffer") |
| 121 | if err != nil { |
| 122 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 123 | } |
| 124 | defer osscip-go gomod github.com/golang/go/src go1.13 os/.Removescip-go gomod github.com/golang/go/src go1.13 os/Remove().(file.Namescip-go gomod github.com/golang/go/src go1.13 os/File#Name().()) |
| 125 | defer file.Closescip-go gomod github.com/golang/go/src go1.13 os/File#Close().() |
| 126 | |
| 127 | b = NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(5, file) |
| 128 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 129 | |
| 130 | b = NewMultiAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMultiAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(1), NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(4, file)) |
| 131 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 132 | |
| 133 | b = NewMultiAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMultiAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(2), NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(3, file)) |
| 134 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 135 | |
| 136 | b = NewMultiAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMultiAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(3), NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(2, file)) |
| 137 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 138 | |
| 139 | b = NewMultiAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMultiAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(4), NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(1, file)) |
| 140 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 141 | |
| 142 | b = NewSwapAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSwapAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(1), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5)) |
| 143 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 144 | |
| 145 | b = NewSwapAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSwapAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(2), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5)) |
| 146 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 147 | |
| 148 | b = NewSwapAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSwapAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(3), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5)) |
| 149 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 150 | |
| 151 | b = NewSwapAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSwapAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(4), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5)) |
| 152 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 153 | |
| 154 | b = NewPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartitionAt().(NewMemPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMemPoolAt().(3)) |
| 155 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 156 | |
| 157 | b = NewPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartitionAt().(NewFilePoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFilePoolAt().(3, osscip-go gomod github.com/golang/go/src go1.13 os/.TempDirscip-go gomod github.com/golang/go/src go1.13 os/TempDir().())) |
| 158 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 159 | |
| 160 | b = NewPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartitionAt().(NewMemPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMemPoolAt().(1)) |
| 161 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 162 | |
| 163 | b = NewPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartitionAt().(NewFilePoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFilePoolAt().(1, osscip-go gomod github.com/golang/go/src go1.13 os/.TempDirscip-go gomod github.com/golang/go/src go1.13 os/TempDir().())) |
| 164 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 165 | |
| 166 | b = NewPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartitionAt().(NewMemPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMemPoolAt().(5)) |
| 167 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 168 | |
| 169 | b = NewPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartitionAt().(NewFilePoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFilePoolAt().(5, osscip-go gomod github.com/golang/go/src go1.13 os/.TempDirscip-go gomod github.com/golang/go/src go1.13 os/TempDir().())) |
| 170 | BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t, b) |
| 171 | } |
| 172 | |
| 173 | func BufferAtTesterscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAtTester().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, b BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt#) { |
| 174 | t.Helperscip-go gomod github.com/golang/go/src go1.13 testing/common#Helper().() |
| 175 | b.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("abc"), 0) |
| 176 | Comparescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Compare().(t, b, "abc") |
| 177 | |
| 178 | b.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("abc"), 1) |
| 179 | Comparescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Compare().(t, b, "aabc") |
| 180 | |
| 181 | b.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("abc"), 2) |
| 182 | Comparescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Compare().(t, b, "aaabc") |
| 183 | |
| 184 | b.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("def"), 3) |
| 185 | switch { |
| 186 | case b.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() > 5: |
| 187 | Comparescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Compare().(t, b, "aaadef") |
| 188 | default: |
| 189 | Comparescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Compare().(t, b, "aaade") |
| 190 | } |
| 191 | |
| 192 | b.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(make([]byte, 2)) |
| 193 | switch { |
| 194 | case b.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() > 5: |
| 195 | Comparescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Compare().(t, b, "adef") |
| 196 | default: |
| 197 | Comparescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Compare().(t, b, "ade") |
| 198 | } |
| 199 | |
| 200 | b.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("ab"), 3) |
| 201 | Comparescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Compare().(t, b, "adeab") |
| 202 | |
| 203 | b.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 204 | } |
| 205 | |
| 206 | func Comparescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Compare().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, b BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt#, s string) { |
| 207 | t.Helperscip-go gomod github.com/golang/go/src go1.13 testing/common#Helper().() |
| 208 | data := make([]byte, b.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.()) |
| 209 | n, _ := b.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 0) |
| 210 | if string(data[:n]) != s { |
| 211 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Mismatch: got %q want %q", string(data[:n]), s) |
| 212 | } |
| 213 | off := int64(len(s) / 2) |
| 214 | n, _ = b.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, off) |
| 215 | if string(data[:n]) != s[off:] { |
| 216 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Mismatch: got %q want %q", string(data[:n]), s[off:]) |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func TestRingComplexscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestRingComplex().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 221 | ringSize := 10 |
| 222 | data := []byte("hello!") |
| 223 | ring := NewRingscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewRing().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(int64(ringSize))) |
| 224 | buf := make([]byte, ringSize) |
| 225 | |
| 226 | for i := 0; i < 10; i++ { |
| 227 | ring.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().(data) |
| 228 | n, err := ring.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(buf) |
| 229 | if err != nil { |
| 230 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("unexpected error %s", err) |
| 231 | } else if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(buf[:n], data) { |
| 232 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected %s got %s", data, buf[:n]) |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | // we are going to overflow the buffer here, we expect the last 10 bytes to remain |
| 237 | repData := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Repeatscip-go gomod github.com/golang/go/src go1.13 bytes/Repeat().(data, 3) |
| 238 | leftover := repData[len(repData)-ringSize:] |
| 239 | for i := 0; i < 10; i++ { |
| 240 | ring.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().(repData) |
| 241 | n, err := ring.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(buf) |
| 242 | if err != nil { |
| 243 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("unexpected error %s", err) |
| 244 | } else if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(buf[:n], leftover) { |
| 245 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected %s got %s", leftover, buf[:n]) |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | func TestRingscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestRing().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 251 | ring := NewRingscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewRing().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(3)) |
| 252 | if ring.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 0 { |
| 253 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Ring non-empty start!") |
| 254 | } |
| 255 | |
| 256 | if ring.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() != mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. { |
| 257 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("Ring has < max capacity") |
| 258 | } |
| 259 | |
| 260 | ring.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("abc")) |
| 261 | if ring.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 3 { |
| 262 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected ring len == 3") |
| 263 | } |
| 264 | |
| 265 | ring.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("de")) |
| 266 | if ring.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 3 { |
| 267 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected ring len == 3") |
| 268 | } |
| 269 | |
| 270 | data := make([]byte, 12) |
| 271 | if n, err := ring.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(data); err != nil { |
| 272 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 273 | } else { |
| 274 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data[:n], []byte("cde")) { |
| 275 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected cde, got %s", data[:n]) |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | if ring.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 0 { |
| 280 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ring should now be empty") |
| 281 | } |
| 282 | |
| 283 | ring.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello")) |
| 284 | ring.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 285 | |
| 286 | if ring.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 0 { |
| 287 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("ring should still be empty") |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | func TestGobscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestGob().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 292 | str := "HelloWorld" |
| 293 | |
| 294 | buf := NewUnboundedBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewUnboundedBuffer().(2, 2) |
| 295 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte(str)) |
| 296 | b := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(nil) |
| 297 | if err := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewEncoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewEncoder().(b).Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&buf); err != nil { |
| 298 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 299 | return |
| 300 | } |
| 301 | var buffer Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# |
| 302 | if err := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewDecoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewDecoder().(b).Decodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Decoder#Decode().(&buffer); err != nil { |
| 303 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 304 | return |
| 305 | } |
| 306 | data := make([]byte, len(str)) |
| 307 | if _, err := buffer.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(data); err != nil && err != ioscip-go gomod github.com/golang/go/src go1.13 io/.EOFscip-go gomod github.com/golang/go/src go1.13 io/EOF. { |
| 308 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 309 | } |
| 310 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data, []byte(str)) { |
| 311 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Gob Recover Failed... " + string(data)) |
| 312 | } |
| 313 | buffer.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 314 | } |
| 315 | |
| 316 | func TestDiscardscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestDiscard().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 317 | buf := Discardscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Discard. |
| 318 | if buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() != mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. { |
| 319 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("cap isn't infinite") |
| 320 | } |
| 321 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello")) |
| 322 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 0 { |
| 323 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("buf should always be empty") |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | func TestListscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestList().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 328 | mem := Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) |
| 329 | ory := Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) |
| 330 | mem.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("Hello")) |
| 331 | ory.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("world")) |
| 332 | |
| 333 | buf := Listscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#([]Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#{mem, ory, Discardscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Discard.}) |
| 334 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Len().() != 10 { |
| 335 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("incorrect sum of lengths") |
| 336 | } |
| 337 | if buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Cap().() != mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. { |
| 338 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("incorrect sum of caps") |
| 339 | } |
| 340 | |
| 341 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Reset().() |
| 342 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Len().() != 0 { |
| 343 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("buffer should be empty") |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | func TestList2scip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestList2().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 348 | mem := Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) |
| 349 | ory := Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) |
| 350 | mem.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("Hello")) |
| 351 | ory.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("world")) |
| 352 | |
| 353 | buf := Listscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#([]Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#{mem, ory}) |
| 354 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Len().() != 10 { |
| 355 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("incorrect sum of lengths") |
| 356 | } |
| 357 | if buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Cap().() != 20 { |
| 358 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("incorrect sum of caps") |
| 359 | } |
| 360 | |
| 361 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Reset().() |
| 362 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Len().() != 0 { |
| 363 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("buffer should be empty") |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | func TestSpillscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestSpill().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 368 | buf := NewSpillscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSpill().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5), Discardscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Discard.) |
| 369 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("Hello World")) |
| 370 | data := make([]byte, 12) |
| 371 | n, _ := buf.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(data) |
| 372 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data[:n], []byte("Hello")) { |
| 373 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("ReadAt Failed. " + string(data[:n])) |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | func TestSpill2scip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestSpill2().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 378 | buf := NewSpillscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSpill().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5), nil) |
| 379 | |
| 380 | if buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() != mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. { |
| 381 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("cap isn't infinite") |
| 382 | } |
| 383 | |
| 384 | towrite := []byte("Hello World") |
| 385 | m, _ := buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().(towrite) |
| 386 | if m != len(towrite) { |
| 387 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("failed to write all data: %d != %d", m, len(towrite)) |
| 388 | } |
| 389 | data := make([]byte, 12) |
| 390 | n, _ := buf.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(data) |
| 391 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data[:n], []byte("Hello")) { |
| 392 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Read Failed. " + string(data[:n])) |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | func TestNoSpillscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestNoSpill().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 397 | buf := NewSpillscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSpill().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(1024), nil) |
| 398 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("Hello World")) |
| 399 | data := make([]byte, 12) |
| 400 | n, _ := buf.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(data) |
| 401 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data[:n], []byte("Hello World")) { |
| 402 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Read Failed. " + string(data[:n])) |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | func TestFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestFile().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 407 | file, err := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.TempFilescip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/TempFile().("", "buffer") |
| 408 | if err != nil { |
| 409 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 410 | } |
| 411 | defer osscip-go gomod github.com/golang/go/src go1.13 os/.Removescip-go gomod github.com/golang/go/src go1.13 os/Remove().(file.Namescip-go gomod github.com/golang/go/src go1.13 os/File#Name().()) |
| 412 | defer file.Closescip-go gomod github.com/golang/go/src go1.13 os/File#Close().() |
| 413 | |
| 414 | buf := NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(1024, file) |
| 415 | checkCapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkCap().(t, buf, 1024) |
| 416 | runPerfectSeriesscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/runPerfectSeries().(t, buf) |
| 417 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 418 | |
| 419 | buf = NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(3, file) |
| 420 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("abc")) |
| 421 | buf.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(make([]byte, 1)) |
| 422 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("a")) |
| 423 | d, _ := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(buf) |
| 424 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(d, []byte("bca")) { |
| 425 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("back and forth error!") |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | func TestMemscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestMem().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 430 | buf := Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(1024) |
| 431 | checkCapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkCap().(t, buf, 1024) |
| 432 | runPerfectSeriesscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/runPerfectSeries().(t, buf) |
| 433 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 434 | if n, err := buf.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("hello"), 1); err == nil || n != 0 { |
| 435 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("write should have failed") |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | func TestFilePartitionscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestFilePartition().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 440 | buf := NewPartitionscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartition().(NewFilePoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFilePool().(1024, "")) |
| 441 | checkCapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkCap().(t, buf, mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64.) |
| 442 | runPerfectSeriesscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/runPerfectSeries().(t, buf) |
| 443 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 444 | } |
| 445 | |
| 446 | func TestSmallMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestSmallMulti().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 447 | if empty := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(); empty != nil { |
| 448 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("the empty buffer should return nil") |
| 449 | } |
| 450 | |
| 451 | one := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10)) |
| 452 | if one.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 0 { |
| 453 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("singleton multi doesn't match inner buffer len") |
| 454 | } |
| 455 | if one.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() != 10 { |
| 456 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("singleton multi doesn't match inner buffer cap") |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | func TestMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestMulti().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 461 | file, err := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.TempFilescip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/TempFile().("", "buffer") |
| 462 | if err != nil { |
| 463 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 464 | } |
| 465 | defer osscip-go gomod github.com/golang/go/src go1.13 os/.Removescip-go gomod github.com/golang/go/src go1.13 os/Remove().(file.Namescip-go gomod github.com/golang/go/src go1.13 os/File#Name().()) |
| 466 | defer file.Closescip-go gomod github.com/golang/go/src go1.13 os/File#Close().() |
| 467 | |
| 468 | buf := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5), NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(500, file), NewPartitionscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartition().(NewFilePoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFilePool().(1024, ""))) |
| 469 | checkCapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkCap().(t, buf, mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64.) |
| 470 | runPerfectSeriesscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/runPerfectSeries().(t, buf) |
| 471 | isPerfectMatchscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/isPerfectMatch().(t, buf, 1024*1024) |
| 472 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 473 | } |
| 474 | |
| 475 | func TestMulti2scip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestMulti2().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 476 | file, err := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.TempFilescip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/TempFile().("", "buffer") |
| 477 | if err != nil { |
| 478 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 479 | } |
| 480 | defer osscip-go gomod github.com/golang/go/src go1.13 os/.Removescip-go gomod github.com/golang/go/src go1.13 os/Remove().(file.Namescip-go gomod github.com/golang/go/src go1.13 os/File#Name().()) |
| 481 | defer file.Closescip-go gomod github.com/golang/go/src go1.13 os/File#Close().() |
| 482 | |
| 483 | buf := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5), NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(500, file)) |
| 484 | checkCapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkCap().(t, buf, 510) |
| 485 | runPerfectSeriesscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/runPerfectSeries().(t, buf) |
| 486 | isPerfectMatchscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/isPerfectMatch().(t, buf, 1024*1024) |
| 487 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 488 | } |
| 489 | |
| 490 | func runPerfectSeriesscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/runPerfectSeries().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, buf Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#) { |
| 491 | checkEmptyscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkEmpty().(t, buf) |
| 492 | simplescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/simple().(t, buf) |
| 493 | |
| 494 | max := int64(1024) |
| 495 | isPerfectMatchscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/isPerfectMatch().(t, buf, 0) |
| 496 | for i := int64(1); i < max; i *= 2 { |
| 497 | isPerfectMatchscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/isPerfectMatch().(t, buf, i) |
| 498 | } |
| 499 | isPerfectMatchscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/isPerfectMatch().(t, buf, max) |
| 500 | } |
| 501 | |
| 502 | func simplescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/simple().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, buf Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#) { |
| 503 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello world")) |
| 504 | data, err := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(buf) |
| 505 | if err != nil { |
| 506 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 507 | } |
| 508 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().([]byte("hello world"), data) { |
| 509 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Hello world failed.") |
| 510 | } |
| 511 | |
| 512 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello world")) |
| 513 | data = make([]byte, 3) |
| 514 | buf.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(data) |
| 515 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte(" yolo")) |
| 516 | data, err = ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(buf) |
| 517 | if err != nil { |
| 518 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err.Error()) |
| 519 | } |
| 520 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().([]byte("lo world yolo"), data) { |
| 521 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Buffer crossing error :(", string(data)) |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | func buildOutputsscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/buildOutputs().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, buf Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#, size int64) (wrote []byte, read []byte) { |
| 526 | r := ioscip-go gomod github.com/golang/go/src go1.13 io/.LimitReaderscip-go gomod github.com/golang/go/src go1.13 io/LimitReader().(randscip-go gomod github.com/golang/go/src go1.13 `crypto/rand`/.Readerscip-go gomod github.com/golang/go/src go1.13 `crypto/rand`/Reader., size) |
| 527 | tee := ioscip-go gomod github.com/golang/go/src go1.13 io/.TeeReaderscip-go gomod github.com/golang/go/src go1.13 io/TeeReader().(r, buf) |
| 528 | |
| 529 | wrote, _ = ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(tee) |
| 530 | read, _ = ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(buf) |
| 531 | |
| 532 | return wrote, read |
| 533 | } |
| 534 | |
| 535 | func isPerfectMatchscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/isPerfectMatch().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, buf Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#, size int64) { |
| 536 | wrote, read := buildOutputsscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/buildOutputs().(t, buf, size) |
| 537 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(wrote, read) { |
| 538 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Buffer should have matched") |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | func checkEmptyscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkEmpty().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, buf Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#) { |
| 543 | if !Emptyscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Empty().(buf) { |
| 544 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Buffer should start empty!") |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | func checkCapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkCap().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#, buf Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#, correctCap int64) { |
| 549 | if buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() != correctCap { |
| 550 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Buffer cap is incorrect", buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.(), correctCap) |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | type bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer# struct{} |
| 555 | |
| 556 | func (b bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#) Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#Len().() int64 { return mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. } |
| 557 | |
| 558 | func (b bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#) Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#Cap().() int64 { return mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. } |
| 559 | |
| 560 | func (b bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#) Readscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#Read().(p []byte) (int, error) { return 0, ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrUnexpectedEOFscip-go gomod github.com/golang/go/src go1.13 io/ErrUnexpectedEOF. } |
| 561 | |
| 562 | func (b bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#) Writescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#Write().(p []byte) (int, error) { return 0, ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrShortBufferscip-go gomod github.com/golang/go/src go1.13 io/ErrShortBuffer. } |
| 563 | |
| 564 | func (b bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#) Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#Reset().() {} |
| 565 | |
| 566 | func TestBigListscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestBigList().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 567 | l := Listscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#([]Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#{bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#{}, bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#{}}) |
| 568 | if l.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Len().() != mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. { |
| 569 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected list to be max-size: %d", l.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/List#Len().()) |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | func TestBigMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestBigMulti().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 574 | single := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#{}) |
| 575 | if single.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. { |
| 576 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected len to be max-size: %d", single.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.()) |
| 577 | } |
| 578 | if single.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() != mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. { |
| 579 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected cap to be max-size: %d", single.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.()) |
| 580 | } |
| 581 | |
| 582 | buf := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#{}, bigBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/bigBuffer#{}) |
| 583 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. { |
| 584 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected len to be max-size: %d", buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.()) |
| 585 | } |
| 586 | if buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() != mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64. { |
| 587 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("expected cap to be max-size: %d", buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.()) |
| 588 | } |
| 589 | |
| 590 | // test defrag failure |
| 591 | NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#{}, badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#{}) |
| 592 | } |
| 593 | |
| 594 | type badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer# struct{} |
| 595 | |
| 596 | func (b badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#) Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#Len().() int64 { return 1024 } |
| 597 | |
| 598 | func (b badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#) Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#Cap().() int64 { return 10 * 1024 } |
| 599 | |
| 600 | func (b badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#) Readscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#Read().(p []byte) (int, error) { return 0, ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrUnexpectedEOFscip-go gomod github.com/golang/go/src go1.13 io/ErrUnexpectedEOF. } |
| 601 | |
| 602 | func (b badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#) Writescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#Write().(p []byte) (int, error) { return 0, ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrShortBufferscip-go gomod github.com/golang/go/src go1.13 io/ErrShortBuffer. } |
| 603 | |
| 604 | func (b badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#) Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#Reset().() {} |
| 605 | |
| 606 | func (b badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#) MarshalBinaryscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#MarshalBinary().() ([]byte, error) { |
| 607 | return nil, errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Newscip-go gomod github.com/golang/go/src go1.13 errors/New().("no data") |
| 608 | } |
| 609 | |
| 610 | func TestBadPartitionscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestBadPartition().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 611 | p := NewPoolscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPool().(func() Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# { return badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#{} }) |
| 612 | buf := NewPartitionscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartition().(p) |
| 613 | _, err := buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("bad write")) |
| 614 | if err != ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrShortBufferscip-go gomod github.com/golang/go/src go1.13 io/ErrShortBuffer. { |
| 615 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("wrong read error was returned! %v", err) |
| 616 | } |
| 617 | |
| 618 | b := make([]byte, 1024) |
| 619 | _, err = buf.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(b) |
| 620 | if err != ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrUnexpectedEOFscip-go gomod github.com/golang/go/src go1.13 io/ErrUnexpectedEOF. { |
| 621 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("wrong write error was returned! %v", err) |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | type fakeFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile# struct { |
| 626 | namescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#name. string |
| 627 | } |
| 628 | |
| 629 | func (f *fakeFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#) Namescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#Name().() string { |
| 630 | return f.namescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#name. |
| 631 | } |
| 632 | |
| 633 | func (f *fakeFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#) Statscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#Stat().() (fi osscip-go gomod github.com/golang/go/src go1.13 os/.FileInfoscip-go gomod github.com/golang/go/src go1.13 os/FileInfo#, err error) { |
| 634 | return nil, nil |
| 635 | } |
| 636 | |
| 637 | func (f *fakeFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#) ReadAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#ReadAt().(p []byte, off int64) (int, error) { |
| 638 | return 0, ioscip-go gomod github.com/golang/go/src go1.13 io/.EOFscip-go gomod github.com/golang/go/src go1.13 io/EOF. |
| 639 | } |
| 640 | |
| 641 | func (f *fakeFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#) WriteAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#WriteAt().(p []byte, off int64) (int, error) { |
| 642 | return 0, ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrShortWritescip-go gomod github.com/golang/go/src go1.13 io/ErrShortWrite. |
| 643 | } |
| 644 | |
| 645 | func (f *fakeFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#) Closescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#Close().() error { return nil } |
| 646 | |
| 647 | func TestBadGobFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestBadGobFile().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 648 | b := NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(10, &fakeFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#{namescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#name.: "test"}) |
| 649 | b2 := NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(10, &fakeFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#{namescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#name.: "test2"}) |
| 650 | b3 := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(b, b2) |
| 651 | buf := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(nil) |
| 652 | enc := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewEncoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewEncoder().(buf) |
| 653 | if err := enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&b3); err != nil { |
| 654 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 655 | } |
| 656 | var buffer Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# |
| 657 | dec := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewDecoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewDecoder().(buf) |
| 658 | if err := dec.Decodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Decoder#Decode().(&buffer); err == nil { |
| 659 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected an error here, file does not exist") |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | func TestBadGobFile2scip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestBadGobFile2().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 664 | b := Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) |
| 665 | b2 := NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(10, &fakeFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#{namescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/fakeFile#name.: "test2"}) |
| 666 | b3 := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(b, b2) |
| 667 | buf := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(nil) |
| 668 | enc := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewEncoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewEncoder().(buf) |
| 669 | if err := enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&b3); err != nil { |
| 670 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 671 | } |
| 672 | var buffer Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# |
| 673 | dec := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewDecoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewDecoder().(buf) |
| 674 | if err := dec.Decodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Decoder#Decode().(&buffer); err == nil { |
| 675 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected an error here, file does not exist") |
| 676 | } |
| 677 | } |
| 678 | |
| 679 | func TestBadMultiGobscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestBadMultiGob().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 680 | var b Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# = badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#{} |
| 681 | var b2 Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# = badBufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badBuffer#{} |
| 682 | var b3 Bufferscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer# = Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) |
| 683 | b4 := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(b, b3) |
| 684 | b5 := NewMultiscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMulti().(b3, b2) |
| 685 | |
| 686 | enc := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewEncoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewEncoder().(ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.Discardscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/Discard.) |
| 687 | if err := enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&b4); err == nil { |
| 688 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected an error here, bad buffer can't be gobbed") |
| 689 | } |
| 690 | if err := enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&b5); err == nil { |
| 691 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected an error here, bad buffer can't be gobbed") |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | func TestSwapAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestSwapAt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 696 | buf := NewSwapAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSwapAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10)) |
| 697 | buf.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("hey"), 0) |
| 698 | data := make([]byte, 10) |
| 699 | n, _ := buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 0) |
| 700 | if string(data[:n]) != "hey" { |
| 701 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected hey got", string(data[:n])) |
| 702 | } |
| 703 | buf.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("hey"), 3) |
| 704 | n, _ = buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 1) |
| 705 | if string(data[:n]) != "eyhey" { |
| 706 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected eyhey got", string(data[:n])) |
| 707 | } |
| 708 | buf.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("hey"), 5) |
| 709 | n, _ = buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 1) |
| 710 | if string(data[:n]) != "eyhehey" { |
| 711 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected eyhehey got", string(data[:n])) |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | func TestSwapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestSwap().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 716 | defer func() { |
| 717 | recover() |
| 718 | }() |
| 719 | buf := NewSwapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSwap().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10)) |
| 720 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 0 { |
| 721 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("buffer should start empty got", buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.()) |
| 722 | } |
| 723 | if buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.() != 10 { |
| 724 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("cap should be second buffer size (10) got", buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Cap.()) |
| 725 | } |
| 726 | ioscip-go gomod github.com/golang/go/src go1.13 io/.WriteStringscip-go gomod github.com/golang/go/src go1.13 io/WriteString().(buf, "hey") |
| 727 | data, _ := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(buf) |
| 728 | if string(data) != "hey" { |
| 729 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected hey got", string(data)) |
| 730 | } |
| 731 | ioscip-go gomod github.com/golang/go/src go1.13 io/.WriteStringscip-go gomod github.com/golang/go/src go1.13 io/WriteString().(buf, "hey") |
| 732 | ioscip-go gomod github.com/golang/go/src go1.13 io/.WriteStringscip-go gomod github.com/golang/go/src go1.13 io/WriteString().(buf, "hey") |
| 733 | ioscip-go gomod github.com/golang/go/src go1.13 io/.WriteStringscip-go gomod github.com/golang/go/src go1.13 io/WriteString().(buf, "hey") |
| 734 | data, _ = ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(buf) |
| 735 | if string(data) != "heyheyhey" { |
| 736 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected heyheyhey got", string(data)) |
| 737 | } |
| 738 | ioscip-go gomod github.com/golang/go/src go1.13 io/.WriteStringscip-go gomod github.com/golang/go/src go1.13 io/WriteString().(buf, "hey") |
| 739 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 3 { |
| 740 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("should have data") |
| 741 | } |
| 742 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 743 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() != 0 { |
| 744 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("should be empty") |
| 745 | } |
| 746 | |
| 747 | runPerfectSeriesscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/runPerfectSeries().(t, NewSwapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSwap().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(512), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(1024))) |
| 748 | |
| 749 | NewSwapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewSwap().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(1), Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(0)) |
| 750 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected panic") |
| 751 | } |
| 752 | |
| 753 | func TestPanicReadAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestPanicReadAt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 754 | defer func() { |
| 755 | recover() |
| 756 | }() |
| 757 | buf := toBufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/toBufferAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5)) |
| 758 | buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(nil, 0) |
| 759 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected a panic!") |
| 760 | } |
| 761 | |
| 762 | func TestPanicWriteAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestPanicWriteAt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 763 | defer func() { |
| 764 | recover() |
| 765 | }() |
| 766 | buf := toBufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/toBufferAt().(Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(5)) |
| 767 | buf.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().(nil, 0) |
| 768 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected a panic!") |
| 769 | } |
| 770 | |
| 771 | type badFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile# struct{} |
| 772 | |
| 773 | func (b badFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#) Namescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#Name().() string { return "" } |
| 774 | func (b badFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#) Statscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#Stat().() (osscip-go gomod github.com/golang/go/src go1.13 os/.FileInfoscip-go gomod github.com/golang/go/src go1.13 os/FileInfo#, error) { return nil, errorsscip-go gomod github.com/golang/go/src go1.13 errors/.Newscip-go gomod github.com/golang/go/src go1.13 errors/New().("unsupported") } |
| 775 | func (b badFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#) ReadAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#ReadAt().(p []byte, off int64) (int, error) { return 0, nil } |
| 776 | func (b badFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#) WriteAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#WriteAt().(p []byte, off int64) (int, error) { return len(p), nil } |
| 777 | func (b badFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#) Closescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#Close().() error { return nil } |
| 778 | |
| 779 | func TestWrapioBreakoutscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestWrapioBreakout().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 780 | buf := NewFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewFile().(10, badFilescip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/badFile#{}) |
| 781 | ioscip-go gomod github.com/golang/go/src go1.13 io/.WriteStringscip-go gomod github.com/golang/go/src go1.13 io/WriteString().(buf, "hello world") |
| 782 | if _, err := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(buf); err != ioscip-go gomod github.com/golang/go/src go1.13 io/.ErrNoProgressscip-go gomod github.com/golang/go/src go1.13 io/ErrNoProgress. { |
| 783 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected no progress to be made") |
| 784 | t.FailNowscip-go gomod github.com/golang/go/src go1.13 testing/common#FailNow().() |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | func TestListAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestListAt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 789 | mem := Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) |
| 790 | ory := Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) |
| 791 | mem.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("Hello")) |
| 792 | ory.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("world")) |
| 793 | |
| 794 | buf := ListAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/ListAt#([]BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt#{mem, ory}) |
| 795 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/ListAt#Len().() != 10 { |
| 796 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("incorrect sum of lengths") |
| 797 | } |
| 798 | if buf.Capscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/ListAt#Cap().() != 20 { |
| 799 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("incorrect sum of caps") |
| 800 | } |
| 801 | |
| 802 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/ListAt#Reset().() |
| 803 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/ListAt#Len().() != 0 { |
| 804 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("buffer should be empty") |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | func TestPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestPoolAt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 809 | pool := NewPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPoolAt().(func() BufferAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/BufferAt# { return Newscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/New().(10) }) |
| 810 | buf, err := pool.Getscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/PoolAt#Get.() |
| 811 | if err != nil { |
| 812 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 813 | } |
| 814 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello world")) |
| 815 | pool.Putscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/PoolAt#Put.(buf) |
| 816 | } |
| 817 | |
| 818 | func TestMemPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestMemPoolAt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 819 | p := NewMemPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMemPoolAt().(10) |
| 820 | poolAtTestscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/poolAtTest().(p, t) |
| 821 | |
| 822 | b := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.13 bytes/NewBuffer().(nil) |
| 823 | enc := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewEncoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewEncoder().(b) |
| 824 | if err := enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Encoder#Encode().(&p); err != nil { |
| 825 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 826 | } |
| 827 | |
| 828 | var pool PoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/PoolAt# |
| 829 | dec := gobscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/.NewDecoderscip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/NewDecoder().(b) |
| 830 | if err := dec.Decodescip-go gomod github.com/golang/go/src go1.13 `encoding/gob`/Decoder#Decode().(&pool); err != nil { |
| 831 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 832 | } |
| 833 | poolAtTestscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/poolAtTest().(pool, t) |
| 834 | } |
| 835 | |
| 836 | func poolAtTestscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/poolAtTest().(pool PoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/PoolAt#, t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 837 | buf, err := pool.Getscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/PoolAt#Get.() |
| 838 | if err != nil { |
| 839 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().(err) |
| 840 | } |
| 841 | if n, err := buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("hello world")); n != 10 { |
| 842 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("wrote incorrect amount") |
| 843 | } else if err == nil { |
| 844 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("should have been a shortwrite error here") |
| 845 | } |
| 846 | pool.Putscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/PoolAt#Put.(buf) |
| 847 | if buf.Lenscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Len.() > 0 { |
| 848 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("should have emptied the buffer") |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | func TestPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestPartitionAt().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 853 | buf := NewPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartitionAt().(NewMemPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMemPoolAt().(5)) |
| 854 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("Hello World")) |
| 855 | data := make([]byte, 12) |
| 856 | n, _ := buf.Readscip-go gomod github.com/golang/go/src go1.13 io/Reader#Read().(data) |
| 857 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data[:n], []byte("Hello World")) { |
| 858 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Read Failed. " + string(data[:n])) |
| 859 | } |
| 860 | |
| 861 | checkCapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkCap().(t, buf, mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64.) |
| 862 | runPerfectSeriesscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/runPerfectSeries().(t, buf) |
| 863 | } |
| 864 | |
| 865 | // TestPartitionAt2 tests ability to read at various offsets from buffer previously written. |
| 866 | func TestPartitionAt2scip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestPartitionAt2().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 867 | buf := NewPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartitionAt().(NewMemPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMemPoolAt().(5)) |
| 868 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().([]byte("Hello World")) |
| 869 | data := make([]byte, 2) |
| 870 | n, _ := buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 2) |
| 871 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data[:n], []byte("ll")) { |
| 872 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Read Failed. " + string(data[:n])) |
| 873 | } |
| 874 | n, _ = buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 4) |
| 875 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data[:n], []byte("o ")) { |
| 876 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Read Failed. " + string(data[:n])) |
| 877 | } |
| 878 | n, _ = buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 10) |
| 879 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data[:n], []byte("d")) { |
| 880 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Read Failed. " + string(data[:n])) |
| 881 | } |
| 882 | n, _ = buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 100) |
| 883 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(data[:n], []byte{}) { |
| 884 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("Read Failed. " + string(data[:n])) |
| 885 | } |
| 886 | |
| 887 | buf.Resetscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/Buffer#Reset.() |
| 888 | checkCapscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/checkCap().(t, buf, mathscip-go gomod github.com/golang/go/src go1.13 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.13 math/MaxInt64.) |
| 889 | runPerfectSeriesscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/runPerfectSeries().(t, buf) |
| 890 | } |
| 891 | |
| 892 | // TestPartitionAt3 tests ability to overwrite buffer previously written. |
| 893 | func TestPartitionAt3scip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/TestPartitionAt3().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 894 | buf := NewPartitionAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewPartitionAt().(NewMemPoolAtscip-go gomod github.com/djherbis/buffer . `github.com/djherbis/buffer`/NewMemPoolAt().(5)) |
| 895 | buf.Writescip-go gomod github.com/golang/go/src go1.13 io/Writer#Write().(make([]byte, 15, 15)) // allocates 3 membuffers |
| 896 | buf.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("hey"), 0) |
| 897 | data := make([]byte, 10) |
| 898 | data = data[:3] |
| 899 | buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 0) |
| 900 | if string(data) != "hey" { |
| 901 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected hey got", string(data)) |
| 902 | } |
| 903 | buf.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("hey"), 3) |
| 904 | data = data[:5] |
| 905 | buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 1) |
| 906 | if string(data) != "eyhey" { |
| 907 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected eyhey got", string(data)) |
| 908 | } |
| 909 | buf.WriteAtscip-go gomod github.com/golang/go/src go1.13 io/WriterAt#WriteAt().([]byte("hey"), 5) |
| 910 | data = data[:7] |
| 911 | buf.ReadAtscip-go gomod github.com/golang/go/src go1.13 io/ReaderAt#ReadAt().(data, 1) |
| 912 | if string(data) != "eyhehey" { |
| 913 | t.Errorscip-go gomod github.com/golang/go/src go1.13 testing/common#Error().("expected eyhehey got", string(data)) |
| 914 | } |
| 915 | } |