diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2007-08-06 08:57:11 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2007-08-06 08:57:11 +0000 |
commit | eb5d2ceee173d65bb166f6ffbe8e7da965f43a4b (patch) | |
tree | 7049d45dd35e6a3ad1dd4f1663e8a56d44854614 /test/c/lists.c | |
parent | 94aea0609bb54f0fde29a558366b646b3b8d21a2 (diff) |
Rendu le test lists.c plus interessant
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@388 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/c/lists.c')
-rw-r--r-- | test/c/lists.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/test/c/lists.c b/test/c/lists.c index c472d72..350d1f0 100644 --- a/test/c/lists.c +++ b/test/c/lists.c @@ -28,6 +28,20 @@ struct list * reverselist (struct list * l) return r; } +struct list * reverse_inplace(struct list * l) +{ + struct list * prev, * next; + + prev = NULL; + while (l != NULL) { + next = l->tl; + l->tl = prev; + prev = l; + l = next; + } + return prev; +} + int checklist(int n, struct list * l) { int i; @@ -41,15 +55,27 @@ int checklist(int n, struct list * l) int main(int argc, char ** argv) { - int n; + int n, niter, i; + struct list * l; - if (argc >= 2) n = atoi(argv[1]); else n = 10; - if (checklist(n, reverselist(buildlist(n)))) { + if (argc >= 2) n = atoi(argv[1]); else n = 1000; + if (argc >= 3) niter = atoi(argv[1]); else niter = 100000; + l = buildlist(n); + if (checklist(n, reverselist(l))) { + printf("OK\n"); + } else { + printf("Bug!\n"); + return 2; + } + for (i = 0; i < 2*niter + 1; i++) { + l = reverse_inplace(l); + } + if (checklist(n, l)) { printf("OK\n"); - return 0; } else { printf("Bug!\n"); return 2; } + return 0; } |