The current tests for varint only check that serialization-deserialization is a roundtrip. That is a useful test, but it is also good to check for some exact bit patterns, to prevent a code change that changes the serialization format from going undetected (or a similar incompatibility between platforms).
As the varint functions are templated, also check with different types.
I wrote this test in the course of diagnosing #7848 and everything turned out to be good, but it makes sense anyhow.