X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flibpspp%2Fsparse-array-test.c;h=e146c3dbf537b7c765dfec60a16267756f8b4356;hb=a68e3f51236286fe02c6c4b6d40efa1bcec36349;hp=c8d14b2bb98f51a95bdf84955cd1b64cc4c87155;hpb=ccead09ac2bc67bbaa40e67904f6c48f7cdf6700;p=pspp-builds.git diff --git a/tests/libpspp/sparse-array-test.c b/tests/libpspp/sparse-array-test.c index c8d14b2b..e146c3db 100644 --- a/tests/libpspp/sparse-array-test.c +++ b/tests/libpspp/sparse-array-test.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,8 @@ in sparse-array.c. This test program aims to be as comprehensive as possible. "gcov -b" should report 100% coverage of lines and branches in sparse-array.c when compiled - with -DNDEBUG. "valgrind --leak-check=yes + with -DNDEBUG and BITS_PER_LEVEL is greater than the number of + bits in a long. "valgrind --leak-check=yes --show-reachable=yes" should give a clean report. */ #ifdef HAVE_CONFIG_H @@ -164,8 +165,8 @@ check_sparse_array (struct sparse_array *spar, check (!sparse_array_remove (spar, order[cnt - 1] + 1)); } - for (i = 0, p = sparse_array_scan (spar, NULL, &idx); i < cnt; - i++, p = sparse_array_scan (spar, &idx, &idx)) + for (i = 0, p = sparse_array_first (spar, &idx); i < cnt; + i++, p = sparse_array_next (spar, idx, &idx)) { check (p != NULL); check (idx == order[i]); @@ -173,6 +174,15 @@ check_sparse_array (struct sparse_array *spar, } check (p == NULL); + for (i = 0, p = sparse_array_last (spar, &idx); i < cnt; + i++, p = sparse_array_prev (spar, idx, &idx)) + { + check (p != NULL); + check (idx == order[cnt - i - 1]); + check (*p == order[cnt - i - 1]); + } + check (p == NULL); + free (order); }