libcruft-util/test/encode/number.cpp

28 lines
621 B
C++
Raw Normal View History

#include "encode/number.hpp"
#include "tap.hpp"
int main ()
{
static struct {
char const *str;
unsigned value;
} const TESTS[] = {
{ "0", 0 },
{ "a", 10 },
{ "A", 10 },
{ "10", 36 },
{ "11", 37 },
{ "bfi0", 533304 },
{ "15bfi0", 69397560 },
};
cruft::TAP::logger tap;
for (auto const &t: TESTS) {
cruft::view src (t.str);
tap.expect_eq (cruft::encode::decode36<unsigned> (src), t.value, "base36 decode '%!'", t.str);
}
return tap.status ();
}