From 239793aa2c318d523cb146968a32cda10389c1bd Mon Sep 17 00:00:00 2001 From: "Luke I. Wilson" Date: Thu, 1 Apr 2021 16:16:47 -0500 Subject: [PATCH] Rope test: add case for TestRopeSlice --- ui/buffer/rope_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ui/buffer/rope_test.go b/ui/buffer/rope_test.go index 62a5d1b..510d03b 100644 --- a/ui/buffer/rope_test.go +++ b/ui/buffer/rope_test.go @@ -113,3 +113,17 @@ func TestRopeCount(t *testing.T) { t.Errorf("Expected no tabs at column zero, got %v", tabs) } } + +func TestRopeSlice(t *testing.T) { + var buf Buffer = NewRopeBuffer([]byte("abc\ndef\n")) + + wholeSlice := buf.Slice(0, 0, 2, 0) // Position points to after the newline char + if string(wholeSlice) != "abc\ndef\n" { + t.Errorf("Whole slice was not equal, got \"%s\"", wholeSlice) + } + + secondLine := buf.Slice(1, 0, 1, 3) + if string(secondLine) != "def\n" { + t.Errorf("Second line and slice were not equal, got \"%s\"", secondLine) + } +}