Просмотр исходного кода

proto: update the library to be in sync with Google's internal code.

R=rsc
CC=golang-dev
http://codereview.appspot.com/1158043
Rob Pike 15 лет назад
Родитель
Сommit
9caa5b9098
3 измененных файлов с 27 добавлено и 26 удалено
  1. 1 0
      proto/all_test.go
  2. 21 21
      proto/text_parser_test.go
  3. 5 5
      proto/text_test.go

+ 1 - 0
proto/all_test.go

@@ -975,6 +975,7 @@ func TestProto1RepeatedGroup(t *testing.T) {
 	}
 }
 
+
 // Test that enums work.  Checks for a bug introduced by making enums
 // named types instead of int32: newInt32FromUint64 would crash with
 // a type mismatch in reflect.PointTo.

+ 21 - 21
proto/text_parser_test.go

@@ -50,7 +50,7 @@ var unMarshalTextTests = []UnmarshalTextTest{
 		in: " count:42\n  name:\"Dave\" ",
 		out: &MyMessage{
 			Count: Int32(42),
-			Name: String("Dave"),
+			Name:  String("Dave"),
 		},
 	},
 
@@ -59,7 +59,7 @@ var unMarshalTextTests = []UnmarshalTextTest{
 		in: `count:42 name:""`,
 		out: &MyMessage{
 			Count: Int32(42),
-			Name: String(""),
+			Name:  String(""),
 		},
 	},
 
@@ -68,49 +68,49 @@ var unMarshalTextTests = []UnmarshalTextTest{
 		in: `count:42 name: "My name is "` + "\n" + `"elsewhere"`,
 		out: &MyMessage{
 			Count: Int32(42),
-			Name: String("My name is elsewhere"),
+			Name:  String("My name is elsewhere"),
 		},
 	},
 
 	// Bad quoted string
 	UnmarshalTextTest{
-		in: `inner: < host: "\0" >` + "\n",
+		in:    `inner: < host: "\0" >` + "\n",
 		error: `line 1.15: invalid quoted string "\0"`,
 	},
 
 	// Number too large for int64
 	UnmarshalTextTest{
-		in: "count: 123456789012345678901",
+		in:    "count: 123456789012345678901",
 		error: "line 1.7: invalid int32: 123456789012345678901",
 	},
 
 	// Number too large for int32
 	UnmarshalTextTest{
-		in: "count: 1234567890123",
+		in:    "count: 1234567890123",
 		error: "line 1.7: invalid int32: 1234567890123",
 	},
 
 	// Number too large for float32
 	UnmarshalTextTest{
-		in: "others:< weight: 12345678901234567890123456789012345678901234567890 >",
+		in:    "others:< weight: 12345678901234567890123456789012345678901234567890 >",
 		error: "line 1.17: invalid float32: 12345678901234567890123456789012345678901234567890",
 	},
 
 	// Number posing as a quoted string
 	UnmarshalTextTest{
-		in: `inner: < host: 12 >` + "\n",
+		in:    `inner: < host: 12 >` + "\n",
 		error: `line 1.15: invalid string: 12`,
 	},
 
 	// Quoted string posing as int32
 	UnmarshalTextTest{
-		in: `count: "12"`,
+		in:    `count: "12"`,
 		error: `line 1.7: invalid int32: "12"`,
 	},
 
 	// Quoted string posing a float32
 	UnmarshalTextTest{
-		in: `others:< weight: "17.4" >`,
+		in:    `others:< weight: "17.4" >`,
 		error: `line 1.17: invalid float32: "17.4"`,
 	},
 
@@ -118,7 +118,7 @@ var unMarshalTextTests = []UnmarshalTextTest{
 	UnmarshalTextTest{
 		in: `count:42 bikeshed: BLUE`,
 		out: &MyMessage{
-			Count: Int32(42),
+			Count:    Int32(42),
 			Bikeshed: NewMyMessage_Color(MyMessage_BLUE),
 		},
 	},
@@ -128,7 +128,7 @@ var unMarshalTextTests = []UnmarshalTextTest{
 		in: `count:42 pet: "horsey" pet:"bunny"`,
 		out: &MyMessage{
 			Count: Int32(42),
-			Pet: []string{"horsey", "bunny"},
+			Pet:   []string{"horsey", "bunny"},
 		},
 	},
 
@@ -145,25 +145,25 @@ var unMarshalTextTests = []UnmarshalTextTest{
 
 	// Missing colon for string field
 	UnmarshalTextTest{
-		in: `name "Dave"`,
+		in:    `name "Dave"`,
 		error: `line 1.5: expected ':', found "\"Dave\""`,
 	},
 
 	// Missing colon for int32 field
 	UnmarshalTextTest{
-		in: `count 42`,
+		in:    `count 42`,
 		error: `line 1.6: expected ':', found "42"`,
 	},
 
 	// Missing required field
 	UnmarshalTextTest{
-		in: ``,
+		in:    ``,
 		error: `line 1.0: message test_proto.MyMessage missing required field "count"`,
 	},
 
 	// Repeated non-repeated field
 	UnmarshalTextTest{
-		in: `name: "Rob" name: "Russ"`,
+		in:    `name: "Rob" name: "Russ"`,
 		error: `line 1.12: non-repeated field "name" was repeated`,
 	},
 
@@ -193,17 +193,17 @@ var unMarshalTextTests = []UnmarshalTextTest{
 			`>`,
 		out: &MyMessage{
 			Count: Int32(42),
-			Name: String("Dave"),
+			Name:  String("Dave"),
 			Quote: String(`"I didn't want to go."`),
-			Pet: []string{"bunny", "kitty", "horsey"},
+			Pet:   []string{"bunny", "kitty", "horsey"},
 			Inner: &InnerMessage{
-				Host: String("footrest.syd"),
-				Port: Int32(7001),
+				Host:      String("footrest.syd"),
+				Port:      Int32(7001),
 				Connected: Bool(true),
 			},
 			Others: []*OtherMessage{
 				&OtherMessage{
-					Key: Int64(3735928559),
+					Key:   Int64(3735928559),
 					Value: []byte{0x1, 'A', '\a', '\f'},
 				},
 				&OtherMessage{

+ 5 - 5
proto/text_test.go

@@ -41,17 +41,17 @@ import (
 func newTestMessage() *MyMessage {
 	return &MyMessage{
 		Count: Int32(42),
-		Name: String("Dave"),
+		Name:  String("Dave"),
 		Quote: String(`"I didn't want to go."`),
-		Pet: []string{"bunny", "kitty", "horsey"},
+		Pet:   []string{"bunny", "kitty", "horsey"},
 		Inner: &InnerMessage{
-			Host: String("footrest.syd"),
-			Port: Int32(7001),
+			Host:      String("footrest.syd"),
+			Port:      Int32(7001),
 			Connected: Bool(true),
 		},
 		Others: []*OtherMessage{
 			&OtherMessage{
-				Key: Int64(0xdeadbeef),
+				Key:   Int64(0xdeadbeef),
 				Value: []byte{1, 65, 7, 12},
 			},
 			&OtherMessage{