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