summaryrefslogtreecommitdiff
path: root/methods_test.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2022-08-30 01:36:46 -0600
committerLuke Shumaker <lukeshu@datawire.io>2022-08-30 01:36:46 -0600
commit8cf459090af5a4e5db0f8c9a4ac21667029f8639 (patch)
tree5e4e38582eaa2a4e4df72bb37548eb6d1764d47d /methods_test.go
parent325838f35ce90080aa6c892a998d960c06c1c144 (diff)
Allow calling lowmemjson.Encode at the root of EncodeJSON
Diffstat (limited to 'methods_test.go')
-rw-r--r--methods_test.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/methods_test.go b/methods_test.go
index 8280a94..a74532c 100644
--- a/methods_test.go
+++ b/methods_test.go
@@ -15,10 +15,17 @@ import (
"git.lukeshu.com/go/lowmemjson"
)
+type ShortSum string
+
+func (s ShortSum) EncodeJSON(w io.Writer) error {
+ // Test that it's OK to call lowmemjson.Encode for the top-level value in a method.
+ return lowmemjson.Encode(w, string(s))
+}
+
type SumRun struct {
ChecksumSize int `json:",omitempty"`
Addr int64 `json:",omitempty"`
- Sums string
+ Sums ShortSum
}
type SumRunWithGaps struct {