github.com/qxnw/lib4go@v0.0.0-20180426074627-c80c7e84b925/utility/utility_test.go (about)

     1  package utility
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/qxnw/lib4go/ut"
     7  )
     8  
     9  // TestGetGUID 测试生成的Guid是否重复
    10  func TestGetGUID(t *testing.T) {
    11  	totalAccount := 10000 * 1000
    12  	data := map[string]int{}
    13  
    14  	for i := 0; i < totalAccount; i++ {
    15  		key := GetGUID()
    16  		data[key] = i
    17  	}
    18  
    19  	if len(data) != totalAccount {
    20  		t.Errorf("test fail, totalAccount:%d, actual:%d", totalAccount, len(data))
    21  	}
    22  }
    23  func TestMapWithQuery1(t *testing.T) {
    24  	m, err := GetMapWithQuery("a=a")
    25  	ut.Expect(t, err, nil)
    26  	ut.Expect(t, len(m), 1)
    27  	ut.Expect(t, m["a"], "a")
    28  }
    29  func TestMapWithQuery2(t *testing.T) {
    30  	m, err := GetMapWithQuery("a=a,b")
    31  	ut.Expect(t, err, nil)
    32  	ut.Expect(t, len(m), 1)
    33  	ut.Expect(t, m["a"], "a,b")
    34  }