Commit d244deb59e

Andrew Kelley <superjoe30@gmail.com>
2017-09-08 15:19:02
fix std.Buffer.endsWith
thanks for the report by jean-dao closes #443
1 parent 2c8ff1d
Changed files (1)
std/buffer.zig
@@ -87,7 +87,7 @@ pub const Buffer = struct {
         const l = self.len();
         if (l < m.len) return false;
         const start = l - m.len;
-        return mem.eql(u8, self.list.items[start..], m);
+        return mem.eql(u8, self.list.items[start..l], m);
     }
 
     pub fn replaceContents(self: &const Buffer, m: []const u8) -> %void {
@@ -111,6 +111,7 @@ test "simple Buffer" {
     assert(buf.eql(buf2.toSliceConst()));
 
     assert(buf.startsWith("hell"));
+    assert(buf.endsWith("orld"));
 
     %%buf2.resize(4);
     assert(buf.startsWith(buf2.toSliceConst()));