37 lines
427 B
Go
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))
|
|
}
|
|
}
|