Skip to content

Allow variable arguments to VTKM_TEST_ASSERT

Kenneth Moreland requested to merge kmorel/vtk-m:better-test-macros into master

The VTKM_TEST_ASSERT macro is a very useful tool for performing checks in tests. However, it is rather annoying to have to always specify a message for the assert. Often the failure is self evident from the condition (which is already printed out), and specifying a message is both repetative and annoying.

Also, it is often equally annoying to print out additional information in the case of an assertion failure. In that case, you have to either attach a debugger or add a printf, see the problem, and remove the printf.

This change solves both of these problems. VTKM_TEST_ASSERT now takes a condition and a variable number of message arguments. If no message arguments are given, then a default message (along with the condition) are output. If multiple message arguments are given, they are appended together in the result. The messages do not have to be strings. Any object that can be sent to a stream will be printed correctly. This allows you to print out the values that caused the issue.

Merge request reports