golib/helper/uniq_helper_test.go

90 lines
1.8 KiB
Go
Raw Normal View History

//
// uniq_helper_test.go
// Copyright (C) 2023 tiglog <me@tiglog.com>
//
// Distributed under terms of the MIT license.
//
package helper_test
import (
"fmt"
"testing"
"git.hexq.cn/tiglog/golib/gtest"
"git.hexq.cn/tiglog/golib/helper"
)
func TestGenId(t *testing.T) {
s1 := helper.GenId()
s2 := helper.GenId()
s3 := helper.GenId()
s4 := helper.GenId()
fmt.Println("gen id: ", s4)
gtest.NotNil(t, s1)
gtest.NotNil(t, s2)
gtest.NotNil(t, s3)
gtest.NotNil(t, s4)
gtest.NotEqual(t, s1, s2)
gtest.NotEqual(t, s1, s3)
gtest.NotEqual(t, s1, s4)
// fmt.Println(s1)
// fmt.Println(s2)
// fmt.Println(s3)
// fmt.Println(s4)
}
func TestUniq(t *testing.T) {
s1 := helper.Uniq(1)
fmt.Println("s1=", s1)
gtest.True(t, 1 == len(s1))
s12 := helper.Uniq(6)
s13 := helper.Uniq(6)
s14 := helper.Uniq(6)
s15 := helper.Uniq(6)
fmt.Println("s12..15", s12, s13, s14, s15)
gtest.NotNil(t, s12)
gtest.NotNil(t, s13)
gtest.NotNil(t, s14)
gtest.NotNil(t, s15)
gtest.NotEqual(t, s12, s13)
gtest.NotEqual(t, s12, s14)
gtest.NotEqual(t, s12, s15)
s2 := helper.Uniq(16)
s3 := helper.Uniq(16)
s4 := helper.Uniq(16)
s5 := helper.Uniq(16)
gtest.NotNil(t, s2)
gtest.NotNil(t, s3)
gtest.NotNil(t, s4)
gtest.NotNil(t, s5)
gtest.NotEqual(t, s2, s3)
gtest.NotEqual(t, s2, s4)
gtest.NotEqual(t, s2, s5)
s6 := helper.Uniq(32)
fmt.Println("s6=", s6)
s7 := helper.Uniq(32)
s8 := helper.Uniq(32)
s9 := helper.Uniq(32)
gtest.NotNil(t, s6)
gtest.NotNil(t, s7)
gtest.NotNil(t, s8)
gtest.NotNil(t, s9)
// fmt.Println("s6789=", s6, s7, s8, s9)
s60 := helper.Uniq(64)
fmt.Println("s60=", s60)
s70 := helper.Uniq(64)
s80 := helper.Uniq(64)
s90 := helper.Uniq(64)
gtest.NotNil(t, s60)
gtest.NotNil(t, s70)
gtest.NotNil(t, s80)
gtest.NotNil(t, s90)
// fmt.Println(s60, s70, s80, s90)
}