File: decoder_test.go

package info (click to toggle)
golang-github-thedevsaddam-gojsonq 2.5.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 476 kB
  • sloc: makefile: 36
file content (21 lines) | stat: -rw-r--r-- 439 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package gojsonq

import (
	"testing"
)

func Test_DefaultDecoder(t *testing.T) {
	dd := DefaultDecoder{}
	var user = struct {
		Name string `json:"name"`
		Age  int    `json:"age"`
	}{}
	if err := dd.Decode([]byte(`{"name": "tom", "age": 27}`), &user); err != nil {
		t.Errorf("failed to decode using default decoder: %v", err)
	}

	if user.Name != "tom" || user.Age != 27 {
		t.Error("failed to decode properly by default decoder")
	}

}