abcex/abcex_test.go
2024-09-20 10:13:21 +03:00

37 lines
587 B
Go

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