Two of the VarInt examples given in the comments of serialize.h are wrong. This is a minor change to correct them.
To verify, you can compute the VarInt encodings of 16511 and 65535 by hand or use the following test program (requires C++11):
#include <iomanip>
#include <iostream>
#include <sstream>
#include <vector>
#include "serialize.h"
int main()
{
std::vector<unsigned long long> inputs = {
0, 1, 127, 128, 255, 256, 16383, 16384, 16511, 65535, (1LL << 32)
};
for (auto& input : inputs) {
std::stringstream output;
WriteVarInt(output, input);
std::cout << std::dec << input << ':';
int c;
while ((c = output.get()) != EOF) {
std::cout << " 0x" << std::hex << std::setw(2) << std::setfill('0') << c;
}
std::cout << std::endl;
}
}