X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Filog%2Ftest%2Frun.c;h=bda59f920a33e115958eeff8b91a6a6a8d2eb966;hp=81935840f8d2b61129fe40a1ea9797d670386140;hb=788c3a4f3469afa00c7414451a5f93e584ce0187;hpb=a5f9a8fbcea19f50aa3594ce2dbf5a13c5455ecc diff --git a/ccan/ilog/test/run.c b/ccan/ilog/test/run.c index 81935840..bda59f92 100644 --- a/ccan/ilog/test/run.c +++ b/ccan/ilog/test/run.c @@ -1,11 +1,7 @@ +#include +#include #include -#include "ilog/ilog.h" -#include "tap/tap.h" -#if defined(__GNUC_PREREQ) -# if __GNUC_PREREQ(4,2) -# pragma GCC diagnostic ignored "-Wparentheses" -# endif -#endif +#include /*Dead simple (but slow) versions to compare against.*/ @@ -24,67 +20,41 @@ static int test_ilog64(uint64_t _v){ #define NTRIALS (64) int main(int _argc,const char *_argv[]){ - int nmatches; int i; int j; /*This is how many tests you plan to run.*/ - plan_tests(2); - nmatches=0; + plan_tests(33 * NTRIALS * 3 + 65 * NTRIALS * 3); for(i=0;i<=32;i++){ uint32_t v; /*Test each bit in turn (and 0).*/ - v=i?(uint32_t)1U<>(33-i>>1)>>(32-i>>1); + v=(1103515245U*v+12345U)&0xFFFFFFFFU>>((33-i)>>1)>>((32-i)>>1); } } - ok1(nmatches==3*(32+1)*NTRIALS); - nmatches=0; + for(i=0;i<=64;i++){ uint64_t v; /*Test each bit in turn (and 0).*/ - v=i?(uint64_t)1U<>(65-i>>1)>>(64-i>>1)); + v=(uint64_t)((2862933555777941757ULL*v+3037000493ULL) + &0xFFFFFFFFFFFFFFFFULL>>((65-i)>>1)>>((64-i)>>1)); } } - ok1(nmatches==3*(64+1)*NTRIALS); return exit_status(); }