48 lines
854 B
Go
48 lines
854 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/pb"
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestSubStr(t *testing.T) {
|
|
str := "type.googleapis.com/UserResChangePush"
|
|
r := SubStr(str, 20, len(str))
|
|
fmt.Println(r)
|
|
}
|
|
|
|
func TestConver(t *testing.T) {
|
|
|
|
s := ConvertFileSize(25325466)
|
|
fmt.Println(s)
|
|
}
|
|
|
|
func TestJsonToPb(t *testing.T) {
|
|
jsonStr := `{"account":"zhaocy","sid":"dfz"}`
|
|
login := &pb.UserLoginReq{}
|
|
Json2Pb(jsonStr, login)
|
|
fmt.Println(login.Account, login.Sid)
|
|
|
|
fmt.Println(Pb2Json(login))
|
|
|
|
t2 := reflect.TypeOf(login)
|
|
fmt.Println("Name:", t2.Elem().Name())
|
|
}
|
|
|
|
func TestSpli(t *testing.T) {
|
|
pbName := "UserLoginReq"
|
|
route := "user.login"
|
|
if strings.HasSuffix(pbName, "Req") {
|
|
s := strings.SplitN(route, ".", 2)
|
|
low := strings.ToLower(pbName)
|
|
if strings.Contains(low, s[0]) &&
|
|
strings.Contains(low, s[1]) {
|
|
|
|
}
|
|
}
|
|
|
|
}
|