projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
format: Always output 2-digit hours for TIME format.
[pspp]
/
tests
/
libpspp
/
sparse-xarray-test.c
diff --git
a/tests/libpspp/sparse-xarray-test.c
b/tests/libpspp/sparse-xarray-test.c
index 798b84267c77f00648b39fc853f6fab668cade29..5354211230d0fd670791185d885044a930e80d8a 100644
(file)
--- a/
tests/libpspp/sparse-xarray-test.c
+++ b/
tests/libpspp/sparse-xarray-test.c
@@
-15,17
+15,12
@@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This is a test program for the sparse array routines defined
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This is a test program for the sparse array routines defined
- in sparse-xarray.c. This test program aims to be as
- comprehensive as possible. "gcov -b" should report 100%
- coverage of lines and branches in sparse-xarray.c when
- compiled with -DNDEBUG. "valgrind --leak-check=yes
- --show-reachable=yes" should give a clean report. */
+ in sparse-xarray.c. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <getopt.h>
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <assert.h>
#include <limits.h>
#include <stdint.h>
@@
-40,7
+35,6
@@
#include <libpspp/sparse-xarray.h>
#include <libpspp/str.h>
#include <libpspp/sparse-xarray.h>
#include <libpspp/str.h>
-#include "error.h"
#include "minmax.h"
#include "progname.h"
#include "xalloc.h"
#include "minmax.h"
#include "progname.h"
#include "xalloc.h"
@@
-79,6
+73,7
@@
test_state_destroy (const struct test_params *params, struct test_state *ts)
for (i = 0; i < params->n_xarrays; i++)
sparse_xarray_destroy (ts->xarrays[i]);
for (i = 0; i < params->n_xarrays; i++)
sparse_xarray_destroy (ts->xarrays[i]);
+ free (ts);
}
static struct test_state *
}
static struct test_state *
@@
-188,7
+183,7
@@
check_state (struct mc *mc, struct test_state *ts, const struct test_model *tm)
for (col = 0; col < params->n_columns; col++)
if (data[col] != model->data[row][col])
{
for (col = 0; col < params->n_columns; col++)
if (data[col] != model->data[row][col])
{
- mc_error (mc, "xarray %d: element %
zu,%zu (of %zu,%zu
) "
+ mc_error (mc, "xarray %d: element %
d,%d (of %d,%d
) "
"differs: %d should be %d",
i, row, col, n_rows, n_columns, data[col],
model->data[row][col]);
"differs: %d should be %d",
i, row, col, n_rows, n_columns, data[col],
model->data[row][col]);
@@
-207,7
+202,7
@@
check_state (struct mc *mc, struct test_state *ts, const struct test_model *tm)
ds_clear (&ds);
for (col = 0; col < n_columns; col++)
ds_put_format (&ds, " %d", model->data[row][col]);
ds_clear (&ds);
for (col = 0; col < n_columns; col++)
ds_put_format (&ds, " %d", model->data[row][col]);
- mc_error (mc, "xarray %d: row %
zu
:%s", i, row, ds_cstr (&ds));
+ mc_error (mc, "xarray %d: row %
d
:%s", i, row, ds_cstr (&ds));
}
mc_error (mc, "xarray %d: actual:", i);
}
mc_error (mc, "xarray %d: actual:", i);
@@
-222,7
+217,7
@@
check_state (struct mc *mc, struct test_state *ts, const struct test_model *tm)
ds_clear (&ds);
for (col = 0; col < n_columns; col++)
ds_put_format (&ds, " %d", data[col]);
ds_clear (&ds);
for (col = 0; col < n_columns; col++)
ds_put_format (&ds, " %d", data[col]);
- mc_error (mc, "xarray %d: row %
zu
:%s", i, row, ds_cstr (&ds));
+ mc_error (mc, "xarray %d: row %
d
:%s", i, row, ds_cstr (&ds));
}
ds_destroy (&ds);
}
ds_destroy (&ds);
@@
-279,8
+274,8
@@
sparse_xarray_mc_init (struct mc *mc)
struct test_model tm;
int i;
struct test_model tm;
int i;
- mc_name_operation (mc, "empty sparse_xarray with n_columns=%
zu
, "
- "max_memory_rows=%
zu
",
+ mc_name_operation (mc, "empty sparse_xarray with n_columns=%
d
, "
+ "max_memory_rows=%
d
",
params->n_columns, params->max_memory_rows);
ts = xmalloc (sizeof *ts);
for (i = 0; i < params->n_xarrays; i++)
params->n_columns, params->max_memory_rows);
ts = xmalloc (sizeof *ts);
for (i = 0; i < params->n_xarrays; i++)
@@
-495,10
+490,11
@@
enum
OPT_NO_WRITE_ROWS,
OPT_NO_WRITE_COLUMNS,
OPT_NO_COPY_COLUMNS,
OPT_NO_WRITE_ROWS,
OPT_NO_WRITE_COLUMNS,
OPT_NO_COPY_COLUMNS,
- OPT_HELP
+ OPT_HELP,
+ N_SPARSE_XARRAY_OPTIONS
};
};
-static struct argv_option sparse_xarray_argv_options[] =
+static struct argv_option sparse_xarray_argv_options[
N_SPARSE_XARRAY_OPTIONS
] =
{
{"columns", 0, required_argument, OPT_COLUMNS},
{"max-rows", 0, required_argument, OPT_MAX_ROWS},
{
{"columns", 0, required_argument, OPT_COLUMNS},
{"max-rows", 0, required_argument, OPT_MAX_ROWS},
@@
-511,8
+507,6
@@
static struct argv_option sparse_xarray_argv_options[] =
{"no-copy-columns", 0, no_argument, OPT_NO_COPY_COLUMNS},
{"help", 'h', no_argument, OPT_HELP},
};
{"no-copy-columns", 0, no_argument, OPT_NO_COPY_COLUMNS},
{"help", 'h', no_argument, OPT_HELP},
};
-enum { N_SPARSE_XARRAY_ARGV_OPTIONS = (sizeof sparse_xarray_argv_options
- / sizeof *sparse_xarray_argv_options) };
static void
sparse_xarray_option_callback (int id, void *params_)
static void
sparse_xarray_option_callback (int id, void *params_)
@@
-600,7
+594,7
@@
main (int argc, char *argv[])
options = mc_options_create ();
mc_options_register_argv_parser (options, parser);
argv_parser_add_options (parser, sparse_xarray_argv_options,
options = mc_options_create ();
mc_options_register_argv_parser (options, parser);
argv_parser_add_options (parser, sparse_xarray_argv_options,
- N_SPARSE_XARRAY_
ARGV_
OPTIONS,
+ N_SPARSE_XARRAY_OPTIONS,
sparse_xarray_option_callback, ¶ms);
if (!argv_parser_run (parser, argc, argv))
exit (EXIT_FAILURE);
sparse_xarray_option_callback, ¶ms);
if (!argv_parser_run (parser, argc, argv))
exit (EXIT_FAILURE);