From 300c28853de206903330aa6b2ff7f0d0130d99ca Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 18 Sep 2024 23:37:57 -0400 Subject: [PATCH] Add another memory test just to be sure --- parse_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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) + } }