blob: 94a8adaf69a9ab6b0ac6edb859fde82c527f39a7 (
plain) (
blame)
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
|
package objx_test
import (
"testing"
"github.com/stretchr/objx"
"github.com/stretchr/testify/assert"
)
func TestHas(t *testing.T) {
m := objx.Map(TestMap)
assert.True(t, m.Has("name"))
assert.True(t, m.Has("address.state"))
assert.True(t, m.Has("numbers[4]"))
assert.False(t, m.Has("address.state.nope"))
assert.False(t, m.Has("address.nope"))
assert.False(t, m.Has("nope"))
assert.False(t, m.Has("numbers[5]"))
m = nil
assert.False(t, m.Has("nothing"))
}
|