diff --git a/parse_test.go b/parse_test.go index f8334e6..752eb23 100644 --- a/parse_test.go +++ b/parse_test.go @@ -123,10 +123,24 @@ func TestParseString (test *testing.T) { } test.Logf("changing first rune from %c to x", runes[0].run) runes[0].run = 'x' + test.Logf("first rune is now %c", runes[0].run) tokenRune := tokens[0].runes[0].run if tokenRune != 'x' { test.Fatalf ( "tokens does not reference the same memory as runes after changing runes: %c, %c", runes[0].run, tokenRune) } + runeIndex := 0 + for tokenIndex, token := range tokens { + tokenRunePtr := &token.runes[0] + runePtr := &runes[runeIndex] + + if runePtr != tokenRunePtr { + test.Fatalf ( + "tokens[%d] does not reference runes[%d]: %p, %p", + tokenIndex, runeIndex, tokenRunePtr, runePtr) + } + + runeIndex += len(token.runes) + } }