github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/cmn/tests/rand_test.go (about)

     1  // Package test provides tests for common low-level types and utilities for all aistore projects
     2  /*
     3   * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package tests_test
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/NVIDIA/aistore/cmn/cos"
    11  	"github.com/NVIDIA/aistore/tools/tassert"
    12  )
    13  
    14  func TestRandStringStrongSmoke(t *testing.T) {
    15  	var (
    16  		ss           = cos.NewStrSet()
    17  		iterations   = 1000
    18  		stringLength = 20
    19  	)
    20  
    21  	for range iterations {
    22  		ss.Add(cos.CryptoRandS(stringLength))
    23  	}
    24  	tassert.Fatalf(t, len(ss) == iterations, "expected to generate %d unique strings, got %d", iterations, len(ss))
    25  }