github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/bfs/hash_test.go (about)

     1  // Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
     2  
     3  package bfs_test
     4  
     5  import (
     6  	"github.com/TeaOSLab/EdgeNode/internal/utils/bfs"
     7  	"github.com/iwind/TeaGo/assert"
     8  	"math/rand"
     9  	"strconv"
    10  	"strings"
    11  	"testing"
    12  )
    13  
    14  func TestCheckHash(t *testing.T) {
    15  	var a = assert.NewAssertion(t)
    16  
    17  	a.IsFalse(bfs.CheckHash("123456"))
    18  	a.IsFalse(bfs.CheckHash(strings.Repeat("A", 32)))
    19  	a.IsTrue(bfs.CheckHash(strings.Repeat("a", 32)))
    20  	a.IsTrue(bfs.CheckHash(bfs.Hash("123456")))
    21  }
    22  
    23  func BenchmarkCheckHashErr(b *testing.B) {
    24  	for i := 0; i < b.N; i++ {
    25  		_ = bfs.CheckHash(bfs.Hash(strconv.Itoa(rand.Int())))
    26  	}
    27  }