1. 18
  1. 7

    Out of curiosity, is the web dead and we now write in groff?

    1. 9

      It’s mdoc, and one can dream.

      1. 3

        Why don’t you remove the top line with “FreeBSD Miscellaneous Information Manual”?

        1. 1

          Ah very well then, I forgive you.

        2. 5

          Just this guy.

        3. 2

          I’ve used CUnit before and was pleased with it.

          1. 2

            I maintain a similar testing framework that adds a few small things on top of assert(), such as pretty printing and rudimentary output filtering. It uses the same mechanism for enabling tests and disabling tests: a macro guard around the test code.



            1. 2

              I’ve used µnit and greatest in the past – granted not as simple as this, but close.

              1. 2

                This misses one key value of unit tests: good names for tests that explain the intent. Because tests by nature are examples. The name helps understand the general rule that the test is a special case of.

                Pretty much the only thing I want from a C/C++ unit-test harness is auto-registry. Don’t make me jump through hoops of initialize_registry() and add_suite() and add_test(). Here’s how I do it at the moment: https://notabug.org/akkartik/basic-test. It requires moulding myself to it a bit, but on the other hand, no dependencies.

                The assembly language I’m working on also provides auto-registry. All it does is compile a new function called run-tests that calls every single function in the codebase that begins with test-.

                1. 2

                  Thank you for your basic test setup. This is all I want from a test infrastructure.

                  1. 1

                    I’m wondering if one could have a nice auto discovery mechanism by having a TEST() macro, which expands into a int test_foo(void) {} that performs the test, plus a little __attribute__((constructor)) void register_test_foo() { register_test(&test_foo, "foo"); }

                    Pehaps make it deterministic instead of relying on the (undefined because we didn’t specify priorities) call order of all those register functions by sorting them by name before invoking them all.

                    1. 1

                      I do something similar in C++: ggunit.h

                      1. 1

                        Ah, using an actual C++ constructor for an object with global lifetime to make the invocation happen, nice.

                  2. 1

                    I’ve found MinUnit to be a pleasant, minimal way to write unit tests in C.

                    1. 1

                      I’ve enjoyed working with libtap. It’s small and effective.