(t *testing.T)
| 98 | } |
| 99 | |
| 100 | func TestBuffer(t *testing.T) { |
| 101 | testCases := []struct { |
| 102 | name string |
| 103 | input string |
| 104 | output string |
| 105 | op func(*testing.T, *Buffer) |
| 106 | }{ |
| 107 | // Preconditions. |
| 108 | { |
| 109 | name: "truncate-check", |
| 110 | input: "hello", |
| 111 | output: "hello", // Not touched. |
| 112 | op: func(t *testing.T, b *Buffer) { |
| 113 | defer func() { |
| 114 | if r := recover(); r == nil { |
| 115 | t.Errorf("Truncate(-1) did not panic") |
| 116 | } |
| 117 | }() |
| 118 | b.Truncate(-1) |
| 119 | }, |
| 120 | }, |
| 121 | { |
| 122 | name: "growto-check", |
| 123 | input: "hello", |
| 124 | output: "hello", // Not touched. |
| 125 | op: func(t *testing.T, b *Buffer) { |
| 126 | defer func() { |
| 127 | if r := recover(); r == nil { |
| 128 | t.Errorf("GrowTo(-1) did not panic") |
| 129 | } |
| 130 | }() |
| 131 | b.GrowTo(-1, false) |
| 132 | }, |
| 133 | }, |
| 134 | { |
| 135 | name: "advance-check", |
| 136 | input: "hello", |
| 137 | output: "", // Consumed. |
| 138 | op: func(t *testing.T, b *Buffer) { |
| 139 | defer func() { |
| 140 | if r := recover(); r == nil { |
| 141 | t.Errorf("advanceRead(Size()+1) did not panic") |
| 142 | } |
| 143 | }() |
| 144 | b.advanceRead(b.Size() + 1) |
| 145 | }, |
| 146 | }, |
| 147 | |
| 148 | // Prepend. |
| 149 | { |
| 150 | name: "prepend", |
| 151 | input: "world", |
| 152 | output: "hello world", |
| 153 | op: func(t *testing.T, b *Buffer) { |
| 154 | b.Prepend(NewViewWithData([]byte("hello "))) |
| 155 | }, |
| 156 | }, |
| 157 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…