github.com/coyove/sdss@v0.0.0-20231129015646-c2ec58cca6a2/contrib/clock/clock_test.go (about)

     1  package clock
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestClockId(t *testing.T) {
     9  	fmt.Println(Unix())
    10  	for i := 0; i < 10; i++ {
    11  		fmt.Println(Id(), ParseIdUnix(Id()), IdStr())
    12  	}
    13  	s := IdStr()
    14  	fmt.Println(s)
    15  	fmt.Println(ParseIdStrUnix(s))
    16  
    17  	fmt.Println(Setup(10, 13))
    18  	fmt.Println(Setup(8, 12))
    19  	fmt.Println(Unix())
    20  	for i := 0; i < 10; i++ {
    21  		fmt.Println(Id(), ParseIdUnix(Id()), IdStr())
    22  	}
    23  	s = UnixToIdStr(30e8)
    24  	fmt.Println(s)
    25  	fmt.Println(ParseIdStrUnix(s))
    26  }
    27  
    28  func BenchmarkParseId(b *testing.B) {
    29  	id := IdStr()
    30  	for i := 0; i < b.N; i++ {
    31  		_, ok := ParseIdStrUnix(id)
    32  		if !ok {
    33  			b.FailNow()
    34  		}
    35  	}
    36  }