corbym / gocrest

GoCrest - Hamcrest-like matchers for Go
BSD 3-Clause "New" or "Revised" License
102 stars 6 forks source link

attempt to fix/lessen some problems mentioned in issue #9 #10

Closed corbym closed 1 year ago

corbym commented 1 year ago

Splits up the Length, Empty and Nil matchers.

Unfortunately, for matchers that work on arrays, maps or pointers will still require the compiler to be told the type of the underlying value. E.g.

// nil pointer, actual is declared as `*string`
then.AssertThat(testing, values.actual, is.NilPtr[string]())
//[]int actual 
then.AssertThat(stubTestingT, test.actual, has.Length[int](test.expected))
// map
then.AssertThat(t, map[string]bool{"hello": true}, has.MapLength[string, bool](1))

.. but vanilla Nil only works on errors and requires no boilerplate types:

then.AssertThat(stubTestingT, someError, is.Nil())

.. would this be more acceptable nitram509? fixes #9

coveralls commented 1 year ago

Coverage Status

Coverage: 100.0%. Remained the same when pulling 9e328838687d8ef9ab9ea2c1ce3442de6945c97f on fix-issue-#9 into 20047551eda8db1d95b80beb3d3dc13d0cde4b64 on master.