int main(int argc, char *argv[]) { log_set_max_level(LOG_DEBUG); log_parse_environment(); log_open(); if (argc == 2) return test_ll(argv[1], NULL); else if (argc == 3) return test_ll(argv[1], argv[2]); else { log_error("This program takes one or two arguments.\n" "\t %s <ifname> [<seed>]", program_invocation_short_name); return EXIT_FAILURE; } }
static void TestLL(void) { static PRInt64 nums[] = { LL_INIT(0, 0), LL_INIT(0, 1), LL_INIT(0xffffffff, 0xffffffff), /* -1 */ LL_INIT(0, 10), LL_INIT(0xffffffff, 0xfffffff6), /* -10 */ LL_INIT(0, 32767), LL_INIT(0xffffffff, 0xffff8000), /* -32768 */ LL_INIT(0, 0x7fffffff), /* 2147483647 */ LL_INIT(0xffffffff, 0x80000000), /* -2147483648 */ LL_INIT(0x7fffffff, 0xffffffff), /* 9223372036854775807 */ LL_INIT(0x80000000, 0) /* -9223372036854775808 */ }; static char *signs[] = { "", "0", "-", "+", " ", "0-", "0+", "0 ", "-0", "-+", "- ", "+0", "+-", "+ ", " 0", " -", " +", "0-+", "0- ", "0+-", "0+ ", "0 -", "0 +", "-0+", "-0 ", "-+0", "-+ ", "- 0", "- +", "+0-", "+0 ", "+-0", "+- ", "+ 0", "+ -", " 0-", " 0+", " -0", " -+", " +0", " +-", "0-+ ", "0- +", "0+- ", "0+ -", "0 -+", "0 +-", "-0+ ", "-0 +", "-+0 ", "-+ 0", "- 0+", "- +0", "+0- ", "+0 -", "+-0 ", "+- 0", "+ 0-", "+ -0", " 0-+", " 0+-", " -0+", " -+0", " +0-", " +-0", }; static char *precs[] = { "", "3", "5", "43", ".3", ".43", "7.3", "7.5", "7.11", "7.43", }; static char *formats[] = { "lld", "llo", "llx", "llu" }; #if PR_BYTES_PER_LONG == 8 static char *sformats[] = { "ld", "lo", "lx", "lu" }; #elif defined(WIN16) /* Watcom uses the format string "%Ld" instead of "%lld". */ static char *sformats[] = { "Ld", "Lo", "Lx", "Lu" }; #elif defined(WIN32) static char *sformats[] = { "I64d", "I64o", "I64x", "I64u" }; #else static char *sformats[] = { "lld", "llo", "llx", "llu" }; #endif int f, s, n, p; char fmt[40], sfmt[40]; for (f = 0; f < countof(formats); f++) { for (s = 0; s < countof(signs); s++) { for (p = 0; p < countof(precs); p++) { fmt[0] = '%'; fmt[1] = 0; if (signs[s]) strcat(fmt, signs[s]); if (precs[p]) strcat(fmt, precs[p]); strcpy(sfmt, fmt); if (formats[f]) strcat(fmt, formats[f]); if (sformats[f]) strcat(sfmt, sformats[f]); for (n = 0; n < countof(nums); n++) { test_ll(fmt, sfmt, nums[n]); } } } } }