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
Compute homomorphic functions of continued fractions.
[frac.git]
/
cf_test.c
blob
2ab03a701394a3d83d512a2e5b8656ce25b32213
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
mpz_add_ui
(
z
,
z
,
1
);
13
cf_put
(
cf
,
z
);
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
=
1
;
i
<=
10
;
i
++) {
25
cf_signal
(
a
);
26
cf_get
(
z
,
a
);
27
EXPECT
(!
mpz_cmp_ui
(
z
,
i
));
28
}
29
cf_free
(
a
);
30
mpz_clear
(
z
);
31
return
0
;
32
}