(t *testing.T)
| 1323 | } |
| 1324 | |
| 1325 | func TestAllSetDefaults(t *testing.T) { |
| 1326 | // Exercise SetDefaults with all scalar field types. |
| 1327 | got := &pb2.Defaults{ |
| 1328 | // NaN != NaN, so override that here. |
| 1329 | F_Nan: proto.Float32(1.7), |
| 1330 | } |
| 1331 | want := &pb2.Defaults{ |
| 1332 | F_Bool: proto.Bool(true), |
| 1333 | F_Int32: proto.Int32(32), |
| 1334 | F_Int64: proto.Int64(64), |
| 1335 | F_Fixed32: proto.Uint32(320), |
| 1336 | F_Fixed64: proto.Uint64(640), |
| 1337 | F_Uint32: proto.Uint32(3200), |
| 1338 | F_Uint64: proto.Uint64(6400), |
| 1339 | F_Float: proto.Float32(314159), |
| 1340 | F_Double: proto.Float64(271828), |
| 1341 | F_String: proto.String(`hello, "world!"` + "\n"), |
| 1342 | F_Bytes: []byte("Bignose"), |
| 1343 | F_Sint32: proto.Int32(-32), |
| 1344 | F_Sint64: proto.Int64(-64), |
| 1345 | F_Enum: pb2.Defaults_GREEN.Enum(), |
| 1346 | F_Pinf: proto.Float32(float32(math.Inf(1))), |
| 1347 | F_Ninf: proto.Float32(float32(math.Inf(-1))), |
| 1348 | F_Nan: proto.Float32(1.7), |
| 1349 | StrZero: proto.String(""), |
| 1350 | } |
| 1351 | proto.SetDefaults(got) |
| 1352 | if !proto.Equal(got, want) { |
| 1353 | t.Errorf("SetDefaults failed\n got %v\nwant %v", got, want) |
| 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | func TestSetDefaultsWithSetField(t *testing.T) { |
| 1358 | // Check that a set value is not overridden. |
nothing calls this directly
no test coverage detected