-
Notifications
You must be signed in to change notification settings - Fork 0
/
int_test.go
33 lines (32 loc) · 1 KB
/
int_test.go
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
// 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 TestInt(t *testing.T) {
var mapOffical = make(map[string]string)
var mapAny = NewInt("mapIntForTest")
//set
for i := 0; i < 10000; i++ {
mapOffical[strconv.Itoa(i)] = strconv.Itoa(i)
mapAny.SetString(i, strconv.Itoa(i))
}
mapAny.SetFinished()
//get
for i := 0; i < 10000; i++ {
valOffical, _ := mapOffical[strconv.Itoa(i)]
valAny, _ := mapAny.GetString(i)
valAnyUnsafe, _ := mapAny.GetUnsafe(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)
}
}
}