Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for json.RawMessage? #62

Open
dionysius opened this issue Mar 22, 2024 · 0 comments
Open

support for json.RawMessage? #62

dionysius opened this issue Mar 22, 2024 · 0 comments

Comments

@dionysius
Copy link

dionysius commented Mar 22, 2024

import "encoding/json"

func TestJsonRawMessage(t *testing.T) {
	type T json.RawMessage

	a := T(`{"foo":1,"bar":2}`)
	b := T(`{"bar":2,"foo":1}`)

	// just informative begin
	aI := map[string]interface{}{}
	bI := map[string]interface{}{}

	_ = json.Unmarshal(a, &aI)
	_ = json.Unmarshal(b, &bI)

	fmt.Println(aI)
	fmt.Println(bI)
	// end

	diff := deep.Equal(a, b)
	if len(diff) != 0 {
		t.Fatalf("expected 0 diff, got %d: %s", len(diff), diff)
	}
}
go test -run ^TestJsonRawMessage$ github.com/go-test/deep

map[bar:2 foo:1]
map[bar:2 foo:1]
--- FAIL: TestJsonRawMessage (0.00s)
    .../deep/deep_test.go:1603: expected 0 diff, got 8: [slice[2]: 102 != 98 slice[3]: 111 != 97 slice[4]: 111 != 114 slice[7]: 49 != 50 slice[10]: 98 != 102 slice[11]: 97 != 111 slice[12]: 114 != 111 slice[15]: 50 != 49]
FAIL
FAIL	github.com/go-test/deep	0.002s
FAIL

might be tricky tho, since the actual type within there can be any json supported type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant