code format

This commit is contained in:
guochao 2023-10-27 13:05:06 +08:00
parent bb69d4de70
commit 61cc2727ca
Signed by: guochao
GPG Key ID: 79F7306D2AA32FC3
3 changed files with 124 additions and 127 deletions

View File

@ -11,8 +11,5 @@ message WithOptional {
message WithOneof {
string username = 1;
oneof optional_userid {
int64 userid = 2;
}
oneof optional_userid { int64 userid = 2; }
}

View File

@ -7,7 +7,7 @@ import (
)
func TestOneofNilId(t *testing.T) {
noid := &WithOneof {
noid := &WithOneof{
Username: "me",
OptionalUserid: nil,
}
@ -31,7 +31,7 @@ func TestOneofZeroId(t *testing.T) {
id := &WithOneof_Userid{
Userid: 0,
}
noid := &WithOneof {
noid := &WithOneof{
Username: "me",
OptionalUserid: id,
}
@ -49,7 +49,7 @@ func TestOneofZeroId(t *testing.T) {
if unmarshaled.OptionalUserid == nil {
t.Fatalf("expected userid is not nil, got %v", unmarshaled.OptionalUserid)
} else if userid, ok := unmarshaled.OptionalUserid.(*WithOneof_Userid); !ok {
t.Fatalf("expected userid is instance of type %T , got %T", &WithOneof_Userid{}, unmarshaled.OptionalUserid )
t.Fatalf("expected userid is instance of type %T , got %T", &WithOneof_Userid{}, unmarshaled.OptionalUserid)
} else if userid.Userid != 0 {
t.Errorf("expected userid is %v, got %v", id, userid.Userid)
} else {
@ -61,7 +61,7 @@ func TestOneofNonZeroId(t *testing.T) {
id := &WithOneof_Userid{
Userid: 1,
}
noid := &WithOneof {
noid := &WithOneof{
Username: "me",
OptionalUserid: id,
}
@ -79,8 +79,8 @@ func TestOneofNonZeroId(t *testing.T) {
if unmarshaled.OptionalUserid == nil {
t.Fatalf("expected userid is not nil, got %v", unmarshaled.OptionalUserid)
} else if userid, ok := unmarshaled.OptionalUserid.(*WithOneof_Userid); !ok {
t.Fatalf("expected userid is instance of type %T , got %T", &WithOneof_Userid{}, unmarshaled.OptionalUserid )
} else if userid.Userid != 1{
t.Fatalf("expected userid is instance of type %T , got %T", &WithOneof_Userid{}, unmarshaled.OptionalUserid)
} else if userid.Userid != 1 {
t.Errorf("expected userid is %v, got %v", id, userid.Userid)
} else {
t.Log("id: ", userid.Userid)

View File

@ -7,7 +7,7 @@ import (
)
func TestOptionalNilId(t *testing.T) {
noid := &WithOptional {
noid := &WithOptional{
Username: "me",
Userid: nil,
}
@ -29,7 +29,7 @@ func TestOptionalNilId(t *testing.T) {
func TestOptionalZeroId(t *testing.T) {
id := int64(0)
noid := &WithOptional {
noid := &WithOptional{
Username: "me",
Userid: &id,
}
@ -51,7 +51,7 @@ func TestOptionalZeroId(t *testing.T) {
func TestOptionalNonZeroId(t *testing.T) {
id := int64(1)
noid := &WithOptional {
noid := &WithOptional{
Username: "me",
Userid: &id,
}