Skip to content

Commit

Permalink
Update testutil/encoding.go
Browse files Browse the repository at this point in the history
Co-authored-by: Jayden Lee <[email protected]>
  • Loading branch information
jaeseung-bae and tkxkd0159 authored Oct 17, 2023
1 parent 4e7d28e commit 0b40b53
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions testutil/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ func MustJSONMarshal(v any) []byte {
return b
}

type FmtStringer interface {
string | sdk.AccAddress | sdk.Int
// W wraps input with double quotes if it is a string or fmt.Stringer.
func W(input any) []byte {
switch input.(type) {
case string, fmt.Stringer:
return []byte(fmt.Sprintf("\"%s\"", input))
default:
panic("unsupported type")
}
}

func W[T FmtStringer](input T) []byte {
return []byte(fmt.Sprintf("\"%s\"", input))
}

0 comments on commit 0b40b53

Please sign in to comment.