github.com/suiyunonghen/DxCommonLib@v0.5.3/stringlist_test.go (about)

     1  package DxCommonLib
     2  
     3  import (
     4  	"fmt"
     5  	"syscall"
     6  	"testing"
     7  	"unsafe"
     8  )
     9  
    10  
    11  func TestStringList(t *testing.T) {
    12  	fmt.Println(Ord(true),Ord(false))
    13  	var lst GStringList
    14  	for i := 0; i < 1000; i++ {
    15  		lst.Add("测试不得闲,adfadfadsfadf1")
    16  	}
    17  	lst.SaveToFile("d:\\t.txt")
    18  	lst.Clear()
    19  	fmt.Println(lst.Text())
    20  	lst.LoadFromFile("d:\\t.txt")
    21  	fmt.Println(lst.Count())
    22  	fmt.Println(lst.Text())
    23  	fmt.Println(lst.Strings(2))
    24  
    25  	lst.Clear()
    26  	lst.AddPair("Name1", "不得闲")
    27  	lst.AddPair("Age", "20")
    28  	fmt.Println(lst.Text())
    29  	fmt.Println(lst.ValueByName("Name1"))
    30  	fmt.Println(lst.ValueFromIndex(1))
    31  	fmt.Println(lst.IndexOfName("Age"))
    32  }
    33  
    34  func TestStringFromUtf8Pointer(t *testing.T) {
    35  	str := "不得闲测试"
    36  	utf16ptr, _ := syscall.UTF16PtrFromString(str)
    37  	fmt.Println(StringFromUtf16Pointer(uintptr(unsafe.Pointer(utf16ptr)), 1024))
    38  }