go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/uuid/v4_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package uuid
     9  
    10  import (
    11  	"fmt"
    12  	"testing"
    13  )
    14  
    15  func Test_V4(t *testing.T) {
    16  	m := make(map[string]bool)
    17  	for x := 1; x < 32; x++ {
    18  		uuid := V4()
    19  		s := fmt.Sprintf("%+v", uuid)
    20  		if m[s] {
    21  			t.Errorf("NewRandom returned duplicated UUID %s\n", s)
    22  		}
    23  		m[s] = true
    24  		if v := uuid.Version(); v != 4 {
    25  			t.Errorf("Random UUID of version %v\n", v)
    26  		}
    27  	}
    28  }