github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/ekatyp/ulid_test.go (about)

     1  // Copyright © 2021. All rights reserved.
     2  // Author: Ilya Stroy.
     3  // Contacts: iyuryevich@pm.me, https://github.com/qioalice
     4  // License: https://opensource.org/licenses/MIT
     5  
     6  package ekatyp_test
     7  
     8  import (
     9  	"fmt"
    10  	"testing"
    11  
    12  	"github.com/json-iterator/go"
    13  
    14  	"github.com/qioalice/ekago/v3/ekatyp"
    15  )
    16  
    17  type (
    18  	T struct {
    19  		ULID ekatyp.ULID `json:"ulid"`
    20  	}
    21  )
    22  
    23  func TestULID_MarshalJSON(t *testing.T) {
    24  	x := T{ULID: ekatyp.ULID_New_OrPanic()}
    25  	encoded, err := jsoniter.Marshal(x)
    26  	fmt.Println(string(encoded), err)
    27  }
    28  
    29  func BenchmarkULID_New(b *testing.B) {
    30  	b.ReportAllocs()
    31  	for i := 0; i < b.N; i++ {
    32  		_ = ekatyp.ULID_New_OrPanic()
    33  	}
    34  }