mirror of
https://github.com/samba-team/samba.git
synced 2025-06-22 07:17:05 +03:00
Based on commit 0284423676209380a2e07086b9b356096a2f93e6 from CCAN: Author: Rusty Russell <rusty@rustcorp.com.au> Date: Tue Jun 21 10:43:31 2011 +0930 tally: fix FreeBSD compile, memleak in tests. Posix says ssize_t is in sys/types.h; on Linux stdlib.h is enough. Autobuild-User: Rusty Russell <rusty@rustcorp.com.au> Autobuild-Date: Tue Jun 21 05:52:12 CEST 2011 on sn-devel-104
22 lines
423 B
C
22 lines
423 B
C
#include <ccan/tally/tally.c>
|
|
#include <ccan/tap/tap.h>
|
|
|
|
int main(void)
|
|
{
|
|
int i;
|
|
struct tally *tally = tally_new(0);
|
|
|
|
plan_tests(100 * 4);
|
|
/* Test max, min and num. */
|
|
for (i = 0; i < 100; i++) {
|
|
tally_add(tally, i);
|
|
ok1(tally_num(tally) == i*2 + 1);
|
|
tally_add(tally, -i);
|
|
ok1(tally_num(tally) == i*2 + 2);
|
|
ok1(tally_max(tally) == i);
|
|
ok1(tally_min(tally) == -i);
|
|
}
|
|
free(tally);
|
|
return exit_status();
|
|
}
|