abcex/abcex_test.go
Arnas Udovic 7823443488
All checks were successful
continuous-integration/drone/push Build is passing
added negative support
2024-08-08 18:25:21 +03:00

37 lines
586 B
Go

package abcex
import (
"testing"
)
func TestEncode(t *testing.T) {
if Encode(12345) != "9ix" {
t.Fatal("Failed encoding")
}
}
func TestDecode(t *testing.T) {
if Decode("9ix") != 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") != -371 {
t.Fatal("Failed negative decoding", Decode("-ab"))
}
}