benbjohnson/testing

Unclear on the usage of the assert function

vendion opened this issue · 1 comments

Looking at the README the usage of the assert function is unclear as it looks like the actual test is happening before this function is being called? if so how is this done? Say I had two structures of the same type that I wanted to make sue that I wanted make sure matched how would I use your assert function to do so or would something like using the equals function or even reflect.DeepEqual be better.

Most other assert implementations I have found take two interfaces as arguments and do the comparison themself but most of what I have seen seem too heavy handed for me like testify/assert or to simple like this one https://gist.github.com/samalba/6059502 (although this may not by to far off from this implementation if I knew how the check is actually done)

I figured out the usage of the conditions I guess I must have been really tired yesterday when I was looking at this as it wasn't very obvious at the time. This is a nice approach instead of having to have different versions of an assert function to do different types of assertions.

That said maybe some usage examples couldn't hurt maybe something like

a := 2
assert(t, a >= 4, "value must be greater than or equal to four")

One thing I'm still confused on is the slice of interfaces at the end of the assert function, I see that they are in the fmt.Printf() call so is that so you can pass in the variables used in the assertion to have them displayed in STDOUT/STDERR?