package abcex import ( "testing" ) func TestConvert(t *testing.T) { if Convert("9ix", BASE36, BASE62) != "3D7" { t.Fatal("Failed conversion") } } func TestEncode36(t *testing.T) { if Encode(12345, BASE36) != "9ix" { t.Fatal("Failed encoding") } } func TestDecode36(t *testing.T) { if Decode("9ix", BASE36) != 12345 { t.Fatal("Failed decoding") } } func TestEncode(t *testing.T) { if Encode(12345, BASE62) != "3D7" { t.Fatal("Failed encoding") } } func TestDecode(t *testing.T) { if Decode("3D7", BASE62) != 12345 { t.Fatal("Failed decoding") } } func TestZero(t *testing.T) { if Encode(0, BASE62) != "0" { t.Fatal("Failed zero encoding") } if Decode("0", BASE62) != 0 { t.Fatal("Failed zero decoding") } } func TestNegative(t *testing.T) { if Encode(-20, BASE62) != "-K" { t.Fatal("Failed negative encoding:", Encode(-20, BASE62)) } if Decode("-ab", BASE62) != -2269 { t.Fatal("Failed negative decoding", Decode("-ab", BASE62)) } }