-
Notifications
You must be signed in to change notification settings - Fork 1
/
prototype_test.go
38 lines (30 loc) · 1.05 KB
/
prototype_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
package prototype
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestDataFrame_Clone(t *testing.T) {
// It's neither data nor frame I know, but it is not the point here, right?
prototype := NewDataFrame("Test DataFrame",
NewData(map[string]any{
"name": "Test",
"category": "Creational",
"pattern": "Prototype",
}))
clone := prototype.Clone()
// assert.Equal runs reflect.DeepEqual that recursively check values
assert.Equal(t, prototype.Data.Map, clone.Data.Map)
clone.Data.Map = map[string]any{
"title": "Prototype, Creational Design Pattern",
"version": 2,
}
assert.NotEqual(t, prototype, clone)
assert.NotSame(t, prototype, clone)
assert.NotSame(t, prototype.Data, clone.Data)
assert.NotSame(t, prototype.Data.Map, clone.Data.Map)
assert.Equal(t, "Prototype", prototype.Data.Map["pattern"])
assert.Equal(t, "Prototype, Creational Design Pattern", clone.Data.Map["title"])
assert.Nil(t, clone.Data.Map["name"])
assert.Nil(t, prototype.Data.Map["version"])
assert.Equal(t, 2, clone.Data.Map["version"])
}