The test is made more robust by not accept trailing characters after 0.
This change was made after the test failed to fail when a bug was introduced (pointer address used instead of the string in a LogPrintf call).
This is a backport of Core PR17893