gh-ost/vendor/github.com/siddontang/go/hack/hack_test.go
2016-06-16 11:15:56 +02:00

37 lines
427 B
Go

package hack
import (
"bytes"
"testing"
)
func TestString(t *testing.T) {
b := []byte("hello world")
a := String(b)
if a != "hello world" {
t.Fatal(a)
}
b[0] = 'a'
if a != "aello world" {
t.Fatal(a)
}
b = append(b, "abc"...)
if a != "aello world" {
t.Fatal(a)
}
}
func TestByte(t *testing.T) {
a := "hello world"
b := Slice(a)
if !bytes.Equal(b, []byte("hello world")) {
t.Fatal(string(b))
}
}