mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-05-23 13:12:15 +00:00
24 lines
499 B
Go
24 lines
499 B
Go
package serializationutil
|
|
|
|
import "testing"
|
|
|
|
func TestItoa(t *testing.T) {
|
|
nums := []int64{0, 1, 2, 3, 4, 1 << 32, int64(1) << 62}
|
|
for _, num := range nums {
|
|
b := Itob(num)
|
|
if v, _ := Btoi(b); v != num {
|
|
t.Errorf("itob/btoi failed for %d", num)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestStob(t *testing.T) {
|
|
strs := []string{"", "a", "ab", "abc", "abcd", "abcde", "abcdef"}
|
|
for _, str := range strs {
|
|
b := Stob(str)
|
|
if val, _, _ := Btos(b); val != str {
|
|
t.Errorf("stob/btos failed for %s", str)
|
|
}
|
|
}
|
|
}
|