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 { message WithOneof {
string username = 1; string username = 1;
oneof optional_userid { oneof optional_userid { int64 userid = 2; }
int64 userid = 2;
}
} }

View File

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

View File

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