-
Notifications
You must be signed in to change notification settings - Fork 4
/
source_test.go
47 lines (43 loc) · 951 Bytes
/
source_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
36
37
38
39
40
41
42
43
44
45
46
47
package mmdbmeld
import (
"fmt"
"testing"
)
func TestMMDBTypes(t *testing.T) {
t.Parallel()
entry := &SourceEntry{
Values: map[string]SourceValue{
"country.iso_code": {
Type: "string",
Value: "AT",
},
"location.latitude": {
Type: "float32",
Value: "48.1230",
},
"location.longitude": {
Type: "float32",
Value: "16.2221",
},
"autonomous_system_organization": {
Type: "string",
Value: "Example Org",
},
"autonomous_system_number": {
Type: "uint32",
Value: "12345",
},
},
}
mmdbMapString := "map[autonomous_system_number:12345 autonomous_system_organization:Example Org country:map[iso_code:AT] location:map[latitude:48.12 longitude:16.22]]"
mmdbMap, err := entry.ToMMDBMap(Optimizations{
FloatDecimals: 2,
})
if err != nil {
t.Fatal(err)
}
s := fmt.Sprintf("%v", mmdbMap)
if s != mmdbMapString {
t.Fatalf("mmdb map string not as expected: %s", s)
}
}