1
0
mirror of https://github.com/samba-team/samba.git synced 2025-06-22 07:17:05 +03:00
samba-mirror/lib/ccan/tally/test/run-min-max.c
Rusty Russell 894b0273fc lib/ccan/tally.h: update for FreeBSD compile.
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
2011-06-21 05:52:12 +02:00

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();
}