| ... | ... | @@ -153,7 +153,7 @@ pub fn LinearFifo( |
| 153 | 153 | var start = self.head + offset; |
| 154 | 154 | if (start >= self.buf.len) { |
| 155 | 155 | start -= self.buf.len; |
| 156 | | return self.buf[start .. self.count - offset]; |
| 156 | return self.buf[start .. start + (self.count - offset)]; |
| 157 | 157 | } else { |
| 158 | 158 | const end = math.min(self.head + self.count, self.buf.len); |
| 159 | 159 | return self.buf[start..end]; |
| ... | ... | @@ -427,6 +427,8 @@ test "LinearFifo(u8, .Dynamic)" { |
| 427 | 427 | fifo.writeAssumeCapacity("6<chars<11"); |
| 428 | 428 | testing.expectEqualSlices(u8, "HELLO6<char", fifo.readableSlice(0)); |
| 429 | 429 | testing.expectEqualSlices(u8, "s<11", fifo.readableSlice(11)); |
| 430 | testing.expectEqualSlices(u8, "11", fifo.readableSlice(13)); |
| 431 | testing.expectEqualSlices(u8, "", fifo.readableSlice(15)); |
| 430 | 432 | fifo.discard(11); |
| 431 | 433 | testing.expectEqualSlices(u8, "s<11", fifo.readableSlice(0)); |
| 432 | 434 | fifo.discard(4); |