I'm writing some unittests with very repetitive tests for a myriad of
different types, so I wrote a helper function:

        version(unittest) {
                void checkConsistency(T...)(T args) {
                        foreach (a; args) {
                                assert(isConsistent(a));
                        }
                }
        }
        unittest {
                A a;
                B b;
                C c;
                checkConsistency(a,b,c);
        }

However, when a consistency check fails, the assert error points to
checkConsistency instead of the unittest, so it's a pain trying to
figure out exactly which test case failed. I tried adding default
arguments to checkConsistency:

        void checkConsistency(T...)(T args, string file=__FILE__,
                size_t line=__LINE__) { ... }

but this causes compile errors because when C==string, then the call is
ambiguous.

Is there an easy of working around this?


T

-- 
To err is human; to forgive is not our policy. -- Samuel Adler

Reply via email to