~ntgg/zosh

4ac7c65e3f0ea2401f37a8e0ddbc056cfe2bf215 — Noah Graff 4 years ago 9359ff1
added tests for TextBuffer.(atPos|sliceRange)
1 files changed, 19 insertions(+), 0 deletions(-)

M src/text_buffer.zig
M src/text_buffer.zig => src/text_buffer.zig +19 -0
@@ 163,4 163,23 @@ test "TextBuffer tests" {
    t.expectEqual(u8('m'), buffer.peekChar().?);
    t.expect(buffer.hasRemaining(5));
    t.expect(!buffer.hasRemaining(6));
    t.expectEqual(
        u8('o'),
        buffer.atPos(TextBuffer.Pos{ .offset = 3, .line = 1, .column = 4 }),
    );
    t.expectEqual(
        u8('o'),
        buffer.atPos(TextBuffer.Pos{ .offset = 3, .line = 420, .column = 69 }),
    );

    t.expectEqualSlices(
        u8,
        "line 2\n",
        buffer.sliceRange(
            TextBuffer.Range{
                .start = TextBuffer.Pos{ .offset = 14, .line = 2, .column = 1 },
                .end = TextBuffer.Pos{ .offset = 22, .line = 2, .column = 9 },
            }
        ),
    );
}