Hamcrest is a matcher framework that is expressive and is used heavily by many test frameworks in various programming languages.
Hamcrest is named for being an anagram of matchers apparently; so is charmset and is a good a reason to name it that as anything else.
Having liked this style of assertion for readability, and realized there is no canonical Go version, I looked around the community for something similar and for one reason or another decided that I would roll my own.
You probably don't want to look at this at the moment:
- It is not well-documented at all
- It is mostly for my personal use and suits my personal tastes
- The APIs are prone to change / breakage until I get happy with it
- I am not a Go expert, there are possibly many dumb things in here
The philosophy was to create a readable fluent API, hence the naming of the matcher packages.
assert.That(probableString, has.Substring("penguins"))
assert.That(probableSliceOfNumbers, has.Item(42))
assert.That(probableMap, has.Key("My Key"))
you can chain them logically
assert.That(probableSliceOfNumbers, has.Item(42).and(has.Item(24)))
assert.That(probableString, has.Substring("penguins").or(has.Prefix("seal")))
you get the idea...
Main package documentation is on GoDoc here: charmset.
Built-in matcher documentation is on GoDoc here: has, is and, matches.