(t *testing.T)
| 89 | } |
| 90 | |
| 91 | func TestLinkBufferGetBytes(t *testing.T) { |
| 92 | buf := NewLinkBuffer() |
| 93 | var ( |
| 94 | num = 10 |
| 95 | b = 1 |
| 96 | expectedLen = 0 |
| 97 | ) |
| 98 | for i := 0; i < num; i++ { |
| 99 | expectedLen += b |
| 100 | n, err := buf.WriteBinary(make([]byte, b)) |
| 101 | MustNil(t, err) |
| 102 | Equal(t, n, b) |
| 103 | b *= 10 |
| 104 | } |
| 105 | buf.Flush() |
| 106 | Equal(t, int(buf.length), expectedLen) |
| 107 | bs := buf.GetBytes(nil) |
| 108 | actualLen := 0 |
| 109 | for i := 0; i < len(bs); i++ { |
| 110 | actualLen += len(bs[i]) |
| 111 | } |
| 112 | Equal(t, actualLen, expectedLen) |
| 113 | } |
| 114 | |
| 115 | // TestLinkBufferWithZero test more case with n is invalid. |
| 116 | func TestLinkBufferWithInvalid(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…