-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathh3database_test.go
More file actions
93 lines (88 loc) · 2.05 KB
/
h3database_test.go
File metadata and controls
93 lines (88 loc) · 2.05 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package h3light_test
import (
"testing"
. "github.com/ThingsIXFoundation/h3-light"
)
func TestDatabaseCellFromCell(t *testing.T) {
type args struct {
cell uint64
}
tests := []struct {
name string
args args
want DatabaseCell
}{
{
name: "test DatabaseCellFromCell(85283473fffffff)=1406434",
args: args{cell: uint64(MustCellFromString("85283473fffffff"))},
want: "1406434",
},
{
name: "test DatabaseCellFromCell(8019fffffffffff)=0c",
args: args{cell: uint64(MustCellFromString("8019fffffffffff"))},
want: "0c",
},
{
name: "test DatabaseCellFromCell(83184dfffffffff)=0c115",
args: args{cell: uint64(MustCellFromString("83184dfffffffff"))},
want: "0c115",
},
{
name: "test DatabaseCellFromCell(83186bfffffffff)=0c153",
args: args{cell: uint64(MustCellFromString("83186bfffffffff"))},
want: "0c153",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := DatabaseCellFromCell(tt.args.cell); got != tt.want {
t.Errorf("DatabaseCellFromCell() = %v, want %v", got, tt.want)
}
})
}
}
func TestDatabaseCell_ToCell(t *testing.T) {
tests := []struct {
name string
dc DatabaseCell
want uint64
}{
{
name: "test res5",
dc: DatabaseCellFromCell(uint64(MustCellFromString("85283473fffffff"))),
want: uint64(MustCellFromString("85283473fffffff")),
},
{
name: "test res0",
dc: DatabaseCellFromCell(uint64(MustCellFromString("8019fffffffffff"))),
want: uint64(MustCellFromString("8019fffffffffff")),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.dc.Cell(); uint64(got) != tt.want {
t.Errorf("ToCell() = %x, want %x", got, tt.want)
}
})
}
}
func TestDatabaseCell_CellPtr(t *testing.T) {
tests := []struct {
name string
dc *DatabaseCell
want *Cell
}{
{
name: "test nil",
dc: nil,
want: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.dc.CellPtr(); got != tt.want {
t.Errorf("DatabaseCell.CellPtr() = %v, want %v", got, tt.want)
}
})
}
}