/* * list_check.c * * Unit test for the reflection list module * * Copyright © 2012-2020 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: * 2011-2013 Thomas White * * This file is part of CrystFEL. * * CrystFEL 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. * * CrystFEL 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 CrystFEL. If not, see . * */ #include #include #include struct refltemp { signed int h; signed int k; signed int l; int num; int found; }; #define RANDOM_INDEX (1022*random()/RAND_MAX - 511) static int test_lists(int num_items) { struct refltemp *check; RefList *list; int i; signed int h, k, l; Reflection *refl; RefListIterator *iter; check = malloc(num_items * sizeof(struct refltemp)); list = reflist_new(); h = RANDOM_INDEX; k = RANDOM_INDEX; l = RANDOM_INDEX; for ( i=0; i RAND_MAX/2 ) { h = RANDOM_INDEX; k = RANDOM_INDEX; l = RANDOM_INDEX; } /* else use the same as last time */ /* Count the number of times this reflection appeared before */ num = 1; for ( j=0; j