16.03.2012 20:23, H. S. Teoh пишет:
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

What happens if you insert some dummy type ?:

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


Reply via email to