Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Boten committed Sep 29, 2022
1 parent a32b62d commit 597cd85
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pdata/pcommon/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ func TestValueMap(t *testing.T) {
assert.Equal(t, NewMap(), m1.Map())
assert.Equal(t, 0, m1.Map().Len())

m1.MapVal().PutDouble("double_key", 123)
assert.Equal(t, 1, m1.MapVal().Len())
got, exists := m1.MapVal().Get("double_key")
m1.Map().PutDouble("double_key", 123)
assert.Equal(t, 1, m1.Map().Len())
got, exists := m1.Map().Get("double_key")
assert.True(t, exists)
assert.Equal(t, NewValueDouble(123), got)

// Create a second map.
m2 := m1.MapVal().PutEmptyMap("child_map")
m2 := m1.Map().PutEmptyMap("child_map")
assert.Equal(t, 0, m2.Len())

// Modify the source map that was inserted.
Expand All @@ -92,13 +92,13 @@ func TestValueMap(t *testing.T) {
assert.Equal(t, NewValueString("somestr"), got)

// Insert the second map as a child. This should perform a deep copy.
assert.EqualValues(t, 2, m1.MapVal().Len())
got, exists = m1.MapVal().Get("double_key")
assert.EqualValues(t, 2, m1.Map().Len())
got, exists = m1.Map().Get("double_key")
assert.True(t, exists)
assert.Equal(t, NewValueDouble(123), got)
got, exists = m1.Map().Get("child_map")
assert.True(t, exists)
assert.Equal(t, m2, got.MapVal())
assert.Equal(t, m2, got.Map())

// Modify the source map m2 that was inserted into m1.
m2.PutString("key_in_child", "somestr2")
Expand All @@ -108,16 +108,16 @@ func TestValueMap(t *testing.T) {
assert.Equal(t, NewValueString("somestr2"), got)

// The child map inside m1 should be modified.
childMap, childMapExists := m1.MapVal().Get("child_map")
childMap, childMapExists := m1.Map().Get("child_map")
require.True(t, childMapExists)
got, exists = childMap.Map().Get("key_in_child")
require.True(t, exists)
assert.Equal(t, NewValueString("somestr2"), got)

// Now modify the inserted map (not the source)
childMap.MapVal().PutString("key_in_child", "somestr3")
assert.EqualValues(t, 1, childMap.MapVal().Len())
got, exists = childMap.MapVal().Get("key_in_child")
childMap.Map().PutString("key_in_child", "somestr3")
assert.EqualValues(t, 1, childMap.Map().Len())
got, exists = childMap.Map().Get("key_in_child")
require.True(t, exists)
assert.Equal(t, NewValueString("somestr3"), got)

Expand Down

0 comments on commit 597cd85

Please sign in to comment.