DinkydauSet / ExploreFractals

A tool for testing the effect of Mandelbrot set Julia morphings
GNU General Public License v3.0
5 stars 1 forks source link

add more assertions #15

Closed DinkydauSet closed 3 years ago

DinkydauSet commented 3 years ago

People talk about the idea of unit tests. I think something similar can be achieved by using assert. assert is defined as:

#ifdef NDEBUG

    #define assert(expression) ((void)0)

#else

    _ACRTIMP void __cdecl _wassert(
        _In_z_ wchar_t const* _Message,
        _In_z_ wchar_t const* _File,
        _In_   unsigned       _Line
        );

    #define assert(expression) (void)(                                                       \
            (!!(expression)) ||                                                              \
            (_wassert(_CRT_WIDE(#expression), _CRT_WIDE(__FILE__), (unsigned)(__LINE__)), 0) \
        )

#endif

in assert.h.

It evaluates to ((void)0) when not compiling in debug mode. That's great because the program won't lose any performance because of assert when not in debug mode.

In debug mode the conditions tested with assert are checked every time. That means all "units" are automatically tested when the program is compiled and used in debug mode.

I want to add more assertions to test as many expected conditions as possible, so that when I run the program compiled in debug mode, it will automatically find more errors and so that I can be 100% sure that if it works, the assertions hold.