-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuint32_test.go
More file actions
34 lines (32 loc) · 1.04 KB
/
uint32_test.go
File metadata and controls
34 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2022 rateLimit Author(https://github.com/yudeguang/noGcStaticMap). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/yudeguang/noGcStaticMap.
package noGcStaticMap
import (
"strconv"
"testing"
)
func TestUint32(t *testing.T) {
var mapOffical = make(map[string]string)
var mapAny = NewUint32("mapUint32ForTest")
//set
for i := 0; i < 10000; i++ {
mapOffical[strconv.Itoa(i)] = strconv.Itoa(i)
mapAny.SetString(uint32(i), strconv.Itoa(i))
}
mapAny.SetFinished()
//get
for i := 0; i < 10000; i++ {
valOffical, _ := mapOffical[strconv.Itoa(i)]
valAny, _ := mapAny.GetString(uint32(i))
valAnyUnsafe, _ := mapAny.GetUnsafe(uint32(i))
if valOffical != valAny {
t.Fatalf("unexpected value obtained; got %q want %q", valAny, valOffical)
}
if valOffical != string(valAnyUnsafe) {
t.Fatalf("unexpected value obtained; got %q want %q", string(valAnyUnsafe), valOffical)
}
}
}