repo.or.cz
/
frac.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Cleaned up lock mess monster.
[frac.git]
/
cf_test.c
blob
5f0fa80245751372301ca442debe6468d00eb5ea
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <gmp.h>
4
#include
"cf.h"
5
#include
"test.h"
6
7
static void
*
count_fn
(
cf_t cf
) {
8
mpz_t z
;
9
mpz_init
(
z
);
10
mpz_set_ui
(
z
,
0
);
11
while
(
cf_wait
(
cf
)) {
12
cf_put
(
cf
,
z
);
13
mpz_add_ui
(
z
,
z
,
1
);
14
}
15
mpz_clear
(
z
);
16
return
NULL
;
17
}
18
19
int
main
() {
20
mpz_t z
;
21
mpz_init
(
z
);
22
cf_t a
;
23
a
=
cf_new
(
count_fn
,
NULL
);
24
for
(
int
i
=
0
;
i
<
100
;
i
++) {
25
cf_get
(
z
,
a
);
26
EXPECT
(!
mpz_cmp_ui
(
z
,
i
));
27
}
28
cf_free
(
a
);
29
mpz_clear
(
z
);
30
return
0
;
31
}