12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package yu_array
- import (
- "fmt"
- "testing"
- "unsafe"
- )
- func TestAppend(t *testing.T) {
- j_arr := []string{"ad", "da", "3", "2"}
- fmt.Println(unsafe.Pointer(&j_arr[0]), len(j_arr), cap(j_arr))
- j_arr = Append(j_arr, "da")
- fmt.Println(j_arr)
- fmt.Println(unsafe.Pointer(&j_arr[0]), len(j_arr), cap(j_arr))
- j_arr = Append(j_arr, "da")
- fmt.Println(j_arr)
- fmt.Println(unsafe.Pointer(&j_arr[0]), len(j_arr), cap(j_arr))
- }
- func TestInsert(t *testing.T) {
- j_arr := []string{"ad", "da", "3", "2"}
- // fmt.Println(unsafe.Pointer(&j_arr[0]), len(j_arr), cap(j_arr))
- // j_arr = Insert(j_arr, 1, "da")
- // fmt.Println(j_arr)
- // fmt.Println(unsafe.Pointer(&j_arr[0]), len(j_arr), cap(j_arr))
- // j_arr = Insert(j_arr, 1, "da")
- // fmt.Println(j_arr)
- // fmt.Println(unsafe.Pointer(&j_arr[0]), len(j_arr), cap(j_arr))
- j_arr = nil
- j_arr = Insert(j_arr, 0, "1")
- fmt.Println(j_arr)
- j_arr = Insert(j_arr, 1, "cccc")
- fmt.Println(j_arr)
- j_arr = Insert(j_arr, 1, "3")
- fmt.Println(j_arr)
- j_arr = Insert(j_arr, 0, "4")
- fmt.Println(j_arr)
- }
- func TestRemove(t *testing.T) {
- j_arr := []string{"ad", "da", "3", "2"}
- fmt.Println(unsafe.Pointer(&j_arr[0]), len(j_arr), cap(j_arr))
- j_arr = Remove(j_arr, 1, 4)
- fmt.Println(j_arr)
- fmt.Println(unsafe.Pointer(&j_arr[0]), len(j_arr), cap(j_arr))
- }
- func TestXor(t *testing.T) {
- j_arr := []byte("asdasdasd")
- j_key := []byte("12412214")
- Xor(j_arr, j_key)
- fmt.Println(j_arr)
- }
- func Test(t *testing.T) {
- j_arr := [4]byte{1, 2, 3, 4}
- fmt.Println(unsafe.Pointer(&j_arr[0]), unsafe.Pointer(&j_arr[:][0]))
- }
|