You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
615 B
Go
35 lines
615 B
Go
package codes
|
|
|
|
import (
|
|
"testing"
|
|
"runtime"
|
|
)
|
|
|
|
func assert(t *testing.T, cond bool) {
|
|
if !cond {
|
|
_, _, line, _ := runtime.Caller(1)
|
|
t.Fatalf("Failed on line %d", line)
|
|
}
|
|
}
|
|
|
|
func TestCodes(t *testing.T) {
|
|
parsed, err := ParseUserCode("AAAA")
|
|
assert(t, err == nil)
|
|
assert(t, int(parsed) == 0)
|
|
|
|
var stringed string
|
|
stringed, err = CodeToString(UserCode(1))
|
|
assert(t, err == nil)
|
|
assert(t, stringed == "AAAB")
|
|
|
|
parsed, err = ParseUserCode("AAAB")
|
|
assert(t, err == nil)
|
|
assert(t, int(parsed) == 1)
|
|
|
|
parsed, err = ParseUserCode("BAAA")
|
|
assert(t, err == nil)
|
|
assert(t, int(parsed) == 46656)
|
|
|
|
}
|
|
|