-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfelt_test.go
80 lines (75 loc) · 1.58 KB
/
felt_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
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
package data
import (
"reflect"
"testing"
"github.com/shopspring/decimal"
)
func Test_NewFromAsciiString(t *testing.T) {
tests := []struct {
name string
s string
want Felt
}{
{
name: "test 1",
s: "uri/pict/t38.jpg",
want: Felt("0x7572692f706963742f7433382e6a7067"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewFromAsciiString(tt.s); got != tt.want {
t.Errorf("Felt.ToShortString() = %v, want %v", got, tt.want)
}
})
}
}
func TestFelt_ToAsciiString(t *testing.T) {
tests := []struct {
name string
f Felt
want string
}{
{
name: "test 1",
f: Felt("0x7572692f706963742f7433382e6a7067"),
want: "uri/pict/t38.jpg",
}, {
name: "test 2",
f: Felt("0x1"),
want: "",
}, {
name: "test 3",
f: Felt("0x0"),
want: string([]byte{0x00}),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.f.ToAsciiString()
if got != tt.want {
t.Errorf("Felt.ToAsciiString() = %v, want %v", got, tt.want)
}
})
}
}
func TestFelt_Decimal(t *testing.T) {
tests := []struct {
name string
f Felt
want decimal.Decimal
}{
{
name: "test 1",
f: Felt("0x0362a8f174e36882a3d8da3ba18e85ff9da5aec5019c8782e3a9273ca7858aa3"),
want: decimal.RequireFromString("1531255561141264586217574535501033622415882562452753316784814711352206920355"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.f.Decimal(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Felt.Decimal() = %v, want %v", got, tt.want)
}
})
}
}