Debian Codegraph @

unmarshaler_test.go

raw ◀ ▶
1 Debian patch touch this file
1 package gojsondiff_test
2
3 import (
4 . "github.com/yudai/gojsondiff"
5
6 . "github.com/onsi/ginkgo"
7 . "github.com/onsi/gomega"
8 . "github.com/yudai/gojsondiff/tests"
9
10 "encoding/json"
11 "fmt"
•12 "github.com/k0kubun/pp"
13 )
14
15 var _ = Describe("Gojsondiff", func() {
16 Describe("Unmarshaller", func() {
17 Describe("CompareObjects", func() {
18 It("", func() {
19 um := NewUnmarshaller()
20 diff, err := um.UnmarshalString(`
21 {
22 "summary": [
23 "@@ -638,17 +638,17 @@\n via, Bra\n-z\n+s\n il, %0ACh\n@@ -916,20 +916,13 @@\n re a\n-lso known as\n+.k.a.\n Car\n",
24 0,
25 2
26 ],
27 "surface": [
28 17840000,
29 0,
30 0
31 ],
32 "demographics": {
33 "population": [
34 385742554,
35 385744896
36 ]
37 },
38 "languages": {
39 "2": [
40 "inglés"
41 ],
42 "_t": "a",
43 "_2": [
44 "english",
45 0,
46 0
47 ]
48 },
49 "countries": {
50 "0": {
51 "capital": [
52 "Buenos Aires",
53 "Rawson"
54 ]
55 },
56 "9": [
57 {
58 "name": "Antártida",
59 "unasur": false
60 }
61 ],
62 "10": {
63 "population": [
64 42888594
65 ]
66 },
67 "_t": "a",
68 "_4": [
69 "",
70 10,
71 3
72 ],
73 "_8": [
74 "",
75 2,
76 3
77 ],
78 "_10": [
79 {
80 "name": "Uruguay",
81 "capital": "Montevideo",
82 "independence": "1825-08-25T07:00:00.000Z",
83 "unasur": true
84 },
85 0,
86 0
87 ],
88 "_11": [
89 {
90 "name": "Venezuela",
91 "capital": "Caracas",
92 "independence": "1811-07-05T07:00:00.000Z",
93 "unasur": true
94 },
95 0,
96 0
97 ]
98 },
99 "spanishName": [
100 "Sudamérica"
101 ]
102 }
103 `)
104 Expect(err).To(BeNil())
105 pp.Print(diff)
106
107 a := LoadFixture("FIXTURES/jsondiffpatch.json")
108 differ := New()
109 differ.ApplyPatch(a, diff)
110 pp.Println(a)
111 result, _ := json.Marshal(a)
112 fmt.Println(string(result))
113 })
114 })
115 })
116 })