X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flibpspp%2Fsparse-array-test.c;h=e146c3dbf537b7c765dfec60a16267756f8b4356;hb=a34c42168e0cd3373860a6cc3f518cb0e329db47;hp=9f63181b6daf3d2c39a0ac483b28bc809002dcd8;hpb=f5c108becd49d78f4898cab11352291f5689d24e;p=pspp-builds.git diff --git a/tests/libpspp/sparse-array-test.c b/tests/libpspp/sparse-array-test.c index 9f63181b..e146c3db 100644 --- a/tests/libpspp/sparse-array-test.c +++ b/tests/libpspp/sparse-array-test.c @@ -1,26 +1,25 @@ -/* PSPP - computes sample statistics. - Copyright (C) 2007 Free Software Foundation, Inc. +/* PSPP - a program for statistical analysis. + 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 the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. */ + along with this program. If not, see . */ /* This is a test program for the sparse array routines defined 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 @@ -166,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]); @@ -175,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); }