-
Notifications
You must be signed in to change notification settings - Fork 0
/
huge_test.go
35 lines (33 loc) · 1.1 KB
/
huge_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
34
35
// 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 TestHuge(t *testing.T) {
var mapOffical = make(map[string]string)
var m = NewHuge("mapHugeForTest")
//set
for i := 0; i < 10000; i++ {
mapOffical[strconv.Itoa(i)] = strconv.Itoa(i)
m.SetString(strconv.Itoa(i), strconv.Itoa(i))
}
m.SetFinished()
//log.Println(m.GetDataBeginPosOfKVPair([]byte(strconv.Itoa(0))))
//get
for i := 0; i < 10000; i++ {
valOffical, _ := mapOffical[strconv.Itoa(i)]
valAny, _ := m.GetString(strconv.Itoa(i))
valAnyUnsafe, _ := m.GetUnsafe([]byte(strconv.Itoa(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)
}
}
}