vote

Vote#1 Results: TEST_ASSERT_EQUAL

We'd like to start by thanking everyone who participated by voting or commenting. We posted the poll as a bit of an experiment. It was hard to predict what kind of response we would get. We were really excited to see how many people participated in this topic! This definitely motivates us to figure out more ways to plan our roadmap and features together!

chart_test_assert_equal.png

The results looked like distribution above. You can see that our opinions are fairly divided, though there are definitely a couple of peaks in sticking with the current behavior (having TEST_ASSERT_EQUAL work as an alias for TEST_ASSERT_EQUAL_INT) and those who want it to be a generic comparison that doesn't really provide details.

There were a number of comments added as well that were also valuable.

  • There was concern that the "Use ==" option would result in cryptic compiler bugs. There are things in C that you just can't compare that way. We all know floats have subtle issues. Even worse, try directly comparing structs and see where that gets you. ;)
  • There are a number of people who voted for integers, but primarily because of momentum / backwards compatibility. Their true preference varied.
  • We did get a couple of people who mentioned MISRA Compliance. This isn't the first time we've heard this (though it's an amusing thing to find on this poll). Please note the contact page. Feel free to send us more detailed information on how we can head in that direction!

Decisions, Decisions.

So where does that leave us on this decision? We try hard not to bloat Unity too badly, but it appears that this is a place where we could easily add some configurability (We know. That was the lowest ranked option... let's discuss).

To keep those upgrading happy (and those who really like Integer as a default option), we'd default to having TEST_ASSERT_EQUAL be an alias for TEST_ASSERT_EQUAL_INT. When people don't love that option, they could use one of these beauties:

  • UNITY_SHORTHAND_AS_INT - Does an integer compare. Since this is the default right now, this does nothing. But by including it, we can get people to start using it and have an excuse to change the default down the road.
  • UNITY_SHORTHAND_AS_MEM - Does a memory compare using sizeof() for len.
  • UNITY_SHORTHAND_AS_RAW - Just uses == to compare. Doesn't give details.
  • UNITY_SHORTHAND_NONE - Will remove this option, replace it with an automatic failure complaining that this isn't a feature anymore.

The nice thing about doing this is that it's really not MUCH more code. The first two are aliases for existing options. The Raw is really just going to use TEST_ASSERT_TRUE under the hood. The None option is just going to use TEST_FAIL_MESSAGE. Bam. Done.

Feel free to comment below if you love / hate this option. We hope to get to this sometime soon, but you have a little time. :)

Please Vote

question-mark-2123967_1920.jpg

Unity has had a TEST_ASSERT_EQUAL macro since the beginning of time (or at least as far back as Unity has existed). More than any other macro, this one has caused confusion. So how WOULD you like to see the TEST_ASSERT_EQUAL (and possibly the TEST_ASSERT_NOT_EQUAL) macro to behave?

We held a vote in this post previously. You can find the results here.