X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftest_nmem.c;fp=test%2Ftest_nmem.c;h=80a2e56d5a005c3de28903e0dacd45a37abc344f;hp=0000000000000000000000000000000000000000;hb=3107ce3a34993d2f784387f227a50343fff83bbc;hpb=ed31c923f03ec124060972f5351b8b33e07a2e13 diff --git a/test/test_nmem.c b/test/test_nmem.c new file mode 100644 index 0000000..80a2e56 --- /dev/null +++ b/test/test_nmem.c @@ -0,0 +1,63 @@ +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2010 Index Data + * See the file LICENSE for details. + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include +#include + +void tst(void) +{ + NMEM n; + int j; + char *cp; + + n = nmem_create(); + YAZ_CHECK(n); + + for (j = 1; j<500; j++) + { + cp = (char *) nmem_malloc(n, j); + YAZ_CHECK(cp); + if ((int) sizeof(long) >= j) + *(long*) cp = 123L; +#if HAVE_LONG_LONG + if ((int) sizeof(long long) >= j) + *(long long*) cp = 123L; +#endif + if ((int) sizeof(double) >= j) + *(double*) cp = 12.2; + } + + for (j = 2000; j<20000; j+= 2000) + { + cp = (char *) nmem_malloc(n, j); + YAZ_CHECK(cp); + } + nmem_destroy(n); +} + +int main (int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); + tst(); + YAZ_CHECK_TERM; +} +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +