copy langext & termext from ffsclient

This commit is contained in:
2022-10-27 16:48:26 +02:00
parent 0eaeb5ac4f
commit 3717eeb515
17 changed files with 606 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
package dataext
import (
"go.mongodb.org/mongo-driver/bson/primitive"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
"math/rand"
"strconv"
"testing"
@@ -251,18 +251,21 @@ func randomKey() string {
}
func randomVal() LRUData {
v := primitive.NewObjectID()
v, err := langext.NewHexUUID()
if err != nil {
panic(err)
}
return &v
}
func eq(a LRUData, b LRUData) bool {
v1, ok1 := a.(*primitive.ObjectID)
v2, ok2 := b.(*primitive.ObjectID)
v1, ok1 := a.(*string)
v2, ok2 := b.(*string)
if ok1 && ok2 {
if v1 == nil || v2 == nil {
return false
}
return v1.Hex() == v2.Hex()
return v1 == v2
}
return false