mirror of https://github.com/rocboss/paopao-ce
parent
e47604b249
commit
21e88a36e5
@ -0,0 +1,36 @@
|
||||
package util
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetIPLoc(t *testing.T) {
|
||||
type args struct {
|
||||
ip string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "test1",
|
||||
args: args{
|
||||
ip: "",
|
||||
},
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "test2",
|
||||
args: args{
|
||||
ip: "103.197.70.244",
|
||||
},
|
||||
want: "香港",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := GetIPLoc(tt.args.ip); got != tt.want {
|
||||
t.Errorf("GetIPLoc() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package util
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEncodeMD5(t *testing.T) {
|
||||
type args struct {
|
||||
value string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "test1",
|
||||
args: args{
|
||||
value: "123456",
|
||||
},
|
||||
want: "e10adc3949ba59abbe56e057f20f883e",
|
||||
},
|
||||
{
|
||||
name: "test2",
|
||||
args: args{
|
||||
value: "",
|
||||
},
|
||||
want: "d41d8cd98f00b204e9800998ecf8427e", // really odd, why?
|
||||
},
|
||||
{
|
||||
name: "test3",
|
||||
args: args{
|
||||
value: "paopaocestr",
|
||||
},
|
||||
want: "8a5033dda1a8919224c66e68d846a289",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := EncodeMD5(tt.args.value); got != tt.want {
|
||||
t.Errorf("EncodeMD5() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in new issue