From ad4c545df006ca0aefdc26109c9fe799d48a2b07 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Wed, 6 Nov 2019 21:40:14 +0100 Subject: [PATCH] Add another match ranges test --- m/matchRanges_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/m/matchRanges_test.go b/m/matchRanges_test.go index 574ee87e..b702c161 100644 --- a/m/matchRanges_test.go +++ b/m/matchRanges_test.go @@ -63,3 +63,13 @@ func TestNoMatch(t *testing.T) { assert.Assert(t, !matchRanges.InRange(3)) assert.Assert(t, !matchRanges.InRange(4)) } + +func TestEndMatch(t *testing.T) { + // This test verifies that the match ranges are by rune rather than by byte + unicodes := "-ä" + matchRanges := GetMatchRanges(&unicodes, regexp.MustCompile("ä")) + + assert.Assert(t, !matchRanges.InRange(0)) // - + assert.Assert(t, matchRanges.InRange(1)) // ä + assert.Assert(t, !matchRanges.InRange(2)) // Past the end +}