github.com/matrixorigin/matrixone@v1.2.0/pkg/util/rand_test.go (about)

     1  // Copyright 2022 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package util
    16  
    17  import (
    18  	"math/rand"
    19  	"testing"
    20  )
    21  
    22  func TestFastrand64(t *testing.T) {
    23  	tests := []struct {
    24  		name    string
    25  		wantNot uint64
    26  	}{
    27  		{
    28  			name:    "normal",
    29  			wantNot: rand.Uint64(),
    30  		},
    31  	}
    32  	for _, tt := range tests {
    33  		t.Run(tt.name, func(t *testing.T) {
    34  			if got := Fastrand64(); got == tt.wantNot {
    35  				t.Errorf("Fastrand64() = %v, wantNot %v", got, tt.wantNot)
    36  			}
    37  		})
    38  	}
    39  }
    40  
    41  func Test_fastrand32(t *testing.T) {
    42  	tests := []struct {
    43  		name    string
    44  		wantNot uint32
    45  	}{
    46  		{
    47  			name:    "normal",
    48  			wantNot: rand.Uint32(),
    49  		},
    50  	}
    51  	for _, tt := range tests {
    52  		t.Run(tt.name, func(t *testing.T) {
    53  			if got := fastrand32(); got == tt.wantNot {
    54  				t.Errorf("fastrand32() = %v, wantNot %v", got, tt.wantNot)
    55  			}
    56  		})
    57  	}
    58  }