Skip to content

Commit

Permalink
add test for encoding map to hash
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-kyosuke committed Sep 30, 2022
1 parent 83bbc67 commit 1f01999
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,17 @@ func TestEncodeStringSlice(t *testing.T) {
t.Error("Slice encoding does not match Ruby")
}
}

func TestEncodeMapStringString(t *testing.T) {
input := map[string]string{"oasis": "disbanded"}
encodedWithRuby := "04087b0649220a6f61736973063a06455449220e64697362616e646564063b0054"

w := bytes.NewBuffer(nil)
if err := NewEncoder(w).Encode(input); err != nil {
t.Error(err.Error())
}

if hex.EncodeToString(w.Bytes()) != encodedWithRuby {
t.Error("Map encoding does not match Ruby")
}
}

0 comments on commit 1f01999

Please sign in to comment.