tests_test.go 476 B

12345678910111213141516171819202122232425
  1. package objx_test
  2. import (
  3. "testing"
  4. "github.com/stretchr/objx"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestHas(t *testing.T) {
  8. m := objx.Map(TestMap)
  9. assert.True(t, m.Has("name"))
  10. assert.True(t, m.Has("address.state"))
  11. assert.True(t, m.Has("numbers[4]"))
  12. assert.False(t, m.Has("address.state.nope"))
  13. assert.False(t, m.Has("address.nope"))
  14. assert.False(t, m.Has("nope"))
  15. assert.False(t, m.Has("numbers[5]"))
  16. m = nil
  17. assert.False(t, m.Has("nothing"))
  18. }