github.com/wangyougui/gf/v2@v2.6.5/util/guid/guid_z_unit_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  // go test *.go -bench=".*"
     8  
     9  package guid_test
    10  
    11  import (
    12  	"testing"
    13  
    14  	"github.com/wangyougui/gf/v2/container/gset"
    15  	"github.com/wangyougui/gf/v2/test/gtest"
    16  	"github.com/wangyougui/gf/v2/util/guid"
    17  )
    18  
    19  func Test_S(t *testing.T) {
    20  	gtest.C(t, func(t *gtest.T) {
    21  		set := gset.NewStrSet()
    22  		for i := 0; i < 1000000; i++ {
    23  			s := guid.S()
    24  			t.Assert(set.AddIfNotExist(s), true)
    25  			t.Assert(len(s), 32)
    26  		}
    27  	})
    28  }
    29  
    30  func Test_S_Data(t *testing.T) {
    31  	gtest.C(t, func(t *gtest.T) {
    32  		t.Assert(len(guid.S([]byte("123"))), 32)
    33  	})
    34  }