aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/encoding
diff options
context:
space:
mode:
authorShawn Smith <shawn.p.smith@gmail.com>2014-01-01 17:54:06 +1100
committerDave Cheney <dave@cheney.net>2014-01-01 17:54:06 +1100
commita39f3b29ec47fb9ed73fc922a44b5e6ff931073d (patch)
treeb73439dd276b58f713d260f42252f747f6f7951f /src/pkg/encoding
parent3c7d2e6af9aced200842b2afa2e9413e5a33e43a (diff)
downloadgo-a39f3b29ec47fb9ed73fc922a44b5e6ff931073d.tar.xz
encoding/json: improve omitempty test coverage
R=golang-codereviews, dave, bradfitz CC=golang-codereviews https://golang.org/cl/46250043
Diffstat (limited to 'src/pkg/encoding')
-rw-r--r--src/pkg/encoding/json/encode_test.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/pkg/encoding/json/encode_test.go b/src/pkg/encoding/json/encode_test.go
index c4a199a1bd..265a237e44 100644
--- a/src/pkg/encoding/json/encode_test.go
+++ b/src/pkg/encoding/json/encode_test.go
@@ -25,13 +25,30 @@ type Optionals struct {
Mr map[string]interface{} `json:"mr"`
Mo map[string]interface{} `json:",omitempty"`
+
+ Fr float64 `json:"fr"`
+ Fo float64 `json:"fo,omitempty"`
+
+ Br bool `json:"br"`
+ Bo bool `json:"bo,omitempty"`
+
+ Ur uint `json:"ur"`
+ Uo uint `json:"uo,omitempty"`
+
+ Str struct{} `json:"str"`
+ Sto struct{} `json:"sto,omitempty"`
}
var optionalsExpected = `{
"sr": "",
"omitempty": 0,
"slr": null,
- "mr": {}
+ "mr": {},
+ "fr": 0,
+ "br": false,
+ "ur": 0,
+ "str": {},
+ "sto": {}
}`
func TestOmitEmpty(t *testing.T) {