2014-04-11 10:21:50 +04:00
|
|
|
package hack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2014-05-09 05:39:23 +04:00
|
|
|
"encoding/binary"
|
2014-04-11 10:21:50 +04:00
|
|
|
"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))
|
|
|
|
}
|
|
|
|
}
|