Add another memory test just to be sure

This commit is contained in:
Sasha Koshka 2024-09-18 23:37:57 -04:00
parent 6fabfd9fd0
commit 300c28853d

View File

@ -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)
}
}