github.com/suiyunonghen/dxcommonlib@v0.0.0-20190612012041-7f8547a81a67/stringlist_test.go (about)

     1  package DxCommonLib
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestStringList(t *testing.T) {
     9  	var lst GStringList
    10  	for i := 0; i < 1000; i++ {
    11  		lst.Add("测试不得闲,adfadfadsfadf1")
    12  	}
    13  	lst.SaveToFile("d:\\t.txt")
    14  	lst.Clear()
    15  	fmt.Println(lst.Text())
    16  	lst.LoadFromFile("d:\\t.txt")
    17  	fmt.Println(lst.Count())
    18  	fmt.Println(lst.Text())
    19  	fmt.Println(lst.Strings(2))
    20  
    21  	lst.Clear()
    22  	lst.AddPair("Name1", "不得闲")
    23  	lst.AddPair("Age", "20")
    24  	fmt.Println(lst.Text())
    25  	fmt.Println(lst.ValueByName("Name1"))
    26  	fmt.Println(lst.ValueFromIndex(1))
    27  	fmt.Println(lst.IndexOfName("Age"))
    28  }
    29