2013-12-27 23:32:55 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEncode(t *testing.T) {
|
|
|
|
strRes := "Cdog"
|
2013-12-28 00:48:44 +02:00
|
|
|
bytes := Encode("dog")
|
|
|
|
str := string(bytes)
|
2013-12-27 23:32:55 +02:00
|
|
|
if str != strRes {
|
|
|
|
t.Error(fmt.Sprintf("Expected %q, got %q", strRes, str))
|
|
|
|
}
|
2013-12-28 00:48:44 +02:00
|
|
|
dec,_ := Decode(bytes, 0)
|
|
|
|
fmt.Printf("raw: %v encoded: %q == %v\n", dec, str, "dog")
|
2013-12-27 23:32:55 +02:00
|
|
|
|
2013-12-28 00:48:44 +02:00
|
|
|
|
|
|
|
sliceRes := "\x83CdogCgodCcat"
|
|
|
|
strs := []string{"dog", "god", "cat"}
|
|
|
|
bytes = Encode(strs)
|
|
|
|
slice := string(bytes)
|
2013-12-27 23:32:55 +02:00
|
|
|
if slice != sliceRes {
|
|
|
|
t.Error(fmt.Sprintf("Expected %q, got %q", sliceRes, slice))
|
|
|
|
}
|
2013-12-28 00:48:44 +02:00
|
|
|
|
|
|
|
dec,_ = Decode(bytes, 0)
|
|
|
|
fmt.Printf("raw: %v encoded: %q == %v\n", dec, slice, strs)
|
2013-12-27 23:32:55 +02:00
|
|
|
}
|