Skip to content

More flexible HaveLen and HaveCap matchers #767

@rgalanakis

Description

@rgalanakis

Hello, long-time Ginkgo/Gomega lover here. I maintain an additional matcher library: https://github.com/rgalanakis/golangal

I know some of them are taste-dependent, but I think the built-in HaveLen and HaveCap matchers can be made more flexible without any downsides:

  • Accept a matcher, rather than an int (ie, HaveLen(BeNumerically(">", 5)))
  • Handle non-built-in-collection types, where they have Len() or Cap() (ie, Expect(bytes.NewBufferString("abc")).To(HaveLength(3)))

I have implementations of these here, or let me know if you'd add this and I can open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions