github.com/angenalZZZ/gofunc@v0.0.0-20210507121333-48ff1be3917b/data/id/shortid/id_test.go (about)

     1  package shortid
     2  
     3  import "testing"
     4  
     5  func TestGetDefault(t *testing.T) {
     6  	id := GetDefault()
     7  	if s, err := id.Generate(); err != nil {
     8  		t.Fatal(err)
     9  	} else {
    10  		t.Log(s)
    11  	}
    12  }
    13  
    14  func TestSetDefault(t *testing.T) {
    15  	id := MustNew(1, DefaultABC, 2048)
    16  	SetDefault(id)
    17  	s := MustGenerate()
    18  	t.Log(s)
    19  }
    20  
    21  func TestMustNewAbc(t *testing.T) {
    22  	abc := MustNewAbc(DefaultABC, 1)
    23  	if id, err := abc.Encode(214235345234524356, 0, 6); err != nil {
    24  		t.Error(err)
    25  	} else if len(id) != 10 {
    26  		t.Errorf("expected 10 symbols")
    27  	}
    28  }