-
Notifications
You must be signed in to change notification settings - Fork 4
/
format_test.go
50 lines (44 loc) · 1.15 KB
/
format_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package deepdiff
import "testing"
func TestFormatPretty(t *testing.T) {
patch := Deltas{
{Type: DTInsert, Path: StringAddr("a"), Value: 5},
{Type: DTUpdate, Path: StringAddr("a"), Value: 5},
{Type: DTDelete, Path: StringAddr("a"), Value: 5},
}
str, err := FormatPrettyString(patch, false)
if err != nil {
t.Fatal(err)
}
// TODO (b5) = need to actually tests this stuff
t.Log(str)
}
func TestFormatStatsPretty(t *testing.T) {
cases := []struct {
description string
input *Stats
expect string
}{
{"all plural",
&Stats{Left: 2, Right: 6, Inserts: 6, Updates: 2, Deletes: 2},
"+4 elements. 6 inserts. 2 deletes. 2 updates.\n",
},
{"all singular",
&Stats{Left: 2, Right: 1, Inserts: 1, Updates: 1, Deletes: 1},
"-1 element. 1 insert. 1 delete. 1 update.\n",
},
}
for i, c := range cases {
got := FormatPrettyStatsString(c.input, false)
if got != c.expect {
t.Errorf("%d %s\nwant:\n%s\ngot:\n%s", i, c.description, c.expect, got)
}
}
}
func TestFormatStatsNull(t *testing.T) {
got := FormatPrettyStatsString(nil, false)
expect := ``
if got != expect {
t.Errorf("want:\n%s\ngot:\n%s", expect, got)
}
}