31 #ifdef GWENHYWFAR_ENABLE_TESTCODE 95 for (i=0; i<100; i++) {
104 if (rv!=(int64_t) i) {
106 i, (
unsigned long) rv, i);
118 (
unsigned long) i, (
unsigned long)
id, (
unsigned long) i+1);
142 for (i=0; i<100; i++) {
167 (
unsigned long) i, (
unsigned long)
id, (
unsigned long) i+1);
197 (
unsigned long) i, (
unsigned long)
id, (
unsigned long) i+1);
227 for (i=0; i<2048; i++) {
233 "Error on GWEN_IdList64_AddEntry(%d): %s (%d)",
237 if (rv!=(int64_t)i) {
238 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv, i);
244 for (i=0; i<8; i++) {
245 GWEN_IDTABLE64 *table;
249 refCounter=table->refCount;
251 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected reference counter in table (list1) %d: is %d, should be 1 ", i, refCounter);
271 for (i=0; i<2048; i++) {
277 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
281 if (rv!=(int64_t)i) {
282 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv, i);
288 for (i=0; i<8; i++) {
289 GWEN_IDTABLE64 *table;
293 refCounter=table->refCount;
295 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected reference counter in table (list1) %d: is %d, should be 1 ", i, refCounter);
318 for (i=0; i<2048; i++) {
324 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
328 if (rv!=(int64_t)i) {
329 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv, i);
336 for (i=0; i<2048; i++) {
342 "Error on GWEN_IdList64_GetIdAt(%d, list1): %s (%d)",
346 if (entry != (int64_t)(i+1)) {
347 DBG_ERROR(
GWEN_LOGDOMAIN,
"Non-matching entry at index %d: is %ld, should be %d ", i, (
unsigned long) entry, i);
352 for (i=0; i<2048; i++) {
358 "Error on GWEN_IdList64_GetIdAt(%d, list2): %s (%d)",
362 if (entry != (int64_t)(i+1)) {
363 DBG_ERROR(
GWEN_LOGDOMAIN,
"Non-matching entry at index %d: is %ld, should be %d ", i, (
unsigned long) entry, i);
369 for (i=0; i<8; i++) {
370 GWEN_IDTABLE64 *table;
374 refCounter=table->refCount;
376 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected reference counter in table (list1) %d: is %d, should be 1 ", i, refCounter);
381 for (i=0; i<8; i++) {
382 GWEN_IDTABLE64 *table;
386 refCounter=table->refCount;
388 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected reference counter in table (list2) %d: is %d, should be 1 ", i, refCounter);
409 for (i=0; i<2048; i++) {
415 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
419 if (rv!=(int64_t)i) {
420 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv, i);
427 for (i=0; i<8; i++) {
428 GWEN_IDTABLE64 *table;
432 refCounter=table->refCount;
441 for (i=0; i<8; i++) {
442 GWEN_IDTABLE64 *table;
446 refCounter=table->refCount;
448 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected reference counter in table (list2) %d: is %d, should be 1 ", i, refCounter);
469 for (i=0; i<2048; i++) {
475 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
479 if (rv!=(int64_t)i) {
480 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv, i);
485 for (i=0; i<8; i++) {
486 GWEN_IDTABLE64 *table;
490 refCounter=table->refCount;
499 for (i=0; i<8; i++) {
500 GWEN_IDTABLE64 *table;
504 refCounter=table->refCount;
511 for (i=0; i<8; i++) {
512 GWEN_IDTABLE64 *table1;
513 GWEN_IDTABLE64 *table2;
517 if (table1!=table2) {
527 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
531 if (iEntry!=(int64_t)2048) {
532 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be 2048", i, (
unsigned long) iEntry);
549 for (i=0; i<8; i++) {
550 GWEN_IDTABLE64 *table;
554 refCounter=table->refCount;
561 for (i=0; i<8; i++) {
562 GWEN_IDTABLE64 *table;
566 refCounter=table->refCount;
573 for (i=8; i<9; i++) {
574 GWEN_IDTABLE64 *table;
578 refCounter=table->refCount;
598 for (i=0; i<2048; i++) {
604 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
608 if (rv!=(int64_t)i) {
609 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv, i);
616 for (i=2048; i<4096; i++) {
622 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
626 if (rv!=(int64_t)i) {
627 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv, i);
633 for (i=0; i<2048; i++) {
639 "Error on GWEN_IdList64_GetIdAt(%d, list1): %s (%d)",
643 if (entry != (int64_t)(i+1)) {
644 DBG_ERROR(
GWEN_LOGDOMAIN,
"Non-matching entry at index %d: is %ld, should be %d ", i, (
unsigned long) entry, i);
654 for (i=0; i<4096; i++) {
660 "Error on GWEN_IdList64_GetIdAt(%d, list2): %s (%d)",
664 if (entry != (int64_t)(i+1)) {
665 DBG_ERROR(
GWEN_LOGDOMAIN,
"Non-matching entry at index %d: is %ld, should be %d ", i, (
unsigned long) entry, i);
676 for (i=0; i<8; i++) {
677 GWEN_IDTABLE64 *table;
681 refCounter=table->refCount;
688 for (i=0; i<8; i++) {
689 GWEN_IDTABLE64 *table;
693 refCounter=table->refCount;
700 for (i=8; i<16; i++) {
701 GWEN_IDTABLE64 *table;
705 refCounter=table->refCount;
715 for (i=0; i<(2048/256); i++) {
716 GWEN_IDTABLE64 *table;
720 refCounter=table->refCount;
722 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected reference counter in table (list2) %d: is %d, should be 1 ", i, refCounter);
741 for (i=0; i<2047; i++) {
747 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
751 if (rv64!=(int64_t)i) {
752 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv64, i);
757 for (i=0; i<8; i++) {
758 GWEN_IDTABLE64 *table;
762 refCounter=table->refCount;
774 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
778 if (rv!=(int64_t)2047) {
779 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be 2047", i, (
unsigned long) rv);
795 for (i=0; i<8; i++) {
796 GWEN_IDTABLE64 *table;
800 refCounter=table->refCount;
807 for (i=0; i<8; i++) {
808 GWEN_IDTABLE64 *table;
812 refCounter=table->refCount;
819 for (i=8; i<8; i++) {
820 GWEN_IDTABLE64 *table;
824 refCounter=table->refCount;
844 for (i=0; i<2048; i++) {
850 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
854 if (rv!=(int64_t)i) {
855 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv, i);
862 for (i=0; i<2048; i++) {
868 "Error on GWEN_IdList64_GetIdAt(%d, list1): %s (%d)",
872 if (entry != (int64_t)(i+1)) {
873 DBG_ERROR(
GWEN_LOGDOMAIN,
"Non-matching entry at index %d: is %ld, should be %d ", i, (
unsigned long) entry, i);
878 for (i=0; i<2048; i++) {
884 "Error on GWEN_IdList64_GetIdAt(%d, list2): %s (%d)",
888 if (entry != (int64_t)(i+1)) {
889 DBG_ERROR(
GWEN_LOGDOMAIN,
"Non-matching entry at index %d: is %ld, should be %d ", i, (
unsigned long) entry, i);
895 for (i=0; i<8; i++) {
896 GWEN_IDTABLE64 *table;
900 refCounter=table->refCount;
902 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected reference counter in table (list1) %d: is %d, should be 1 ", i, refCounter);
907 for (i=0; i<8; i++) {
908 GWEN_IDTABLE64 *table;
912 refCounter=table->refCount;
914 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected reference counter in table (list2) %d: is %d, should be 1 ", i, refCounter);
936 for (i=0; i<2048; i++) {
942 "Error on GWEN_IdList64_AddId(%d): %s (%d)",
946 if (rv64!=(int64_t)i) {
947 DBG_ERROR(
GWEN_LOGDOMAIN,
"Unexpected index returned for entry %d: is %ld, should be %d ", i, (
unsigned long) rv64, i);
955 rv=_compareList1AgainstList2(ptrList1, ptrList2);
985 while (id1>0 && id2>0) {
987 fprintf(stderr,
"Tables differ at position %lu (%lu != %lu)\n",
988 (
unsigned long) index,
990 (
unsigned long) id2);
1000 fprintf(stderr,
"NUmber of elements in lists differs\n");
int test10(int argc, char **argv)
int test5(int argc, char **argv)
int test3(int argc, char **argv)
GWEN_IDLIST64 * GWEN_IdList64_dup(const GWEN_IDLIST64 *oldList)
int test6(int argc, char **argv)
int test9(int argc, char **argv)
int test2(int argc, char **argv)
int GWEN_IdList64_Sort(GWEN_IDLIST64 *idl)
void GWEN_IdList64_free(GWEN_IDLIST64 *idl)
static GWEN_IDTABLE64 * GWEN_IdList64_GetTableAt(const GWEN_IDLIST64 *tl, uint64_t idx)
void GWEN_IdList64_Iterator_free(GWEN_IDLIST64_ITERATOR *it)
GWEN_IDLIST64 * GWEN_IdList64_newWithSteps(uint64_t steps)
GWEN_TEST_MODULE * GWEN_Test_Module_AddTest(GWEN_TEST_MODULE *st, const char *tName, GWEN_TEST_MODULE_TEST_FN fn, const char *tDescr)
int test8(int argc, char **argv)
GWEN_SIMPLEPTRLIST GWEN_IDLIST64
int64_t GWEN_IdList64_GetIdAt(const GWEN_IDLIST64 *idl, uint64_t idx)
uint64_t GWEN_IdList64_Iterator_GetFirstId(GWEN_IDLIST64_ITERATOR *it)
struct GWEN_TEST_MODULE GWEN_TEST_MODULE
#define GWEN_ERROR_GENERIC
GWEN_IDLIST64_ITERATOR * GWEN_IdList64_Iterator_new(const GWEN_IDLIST64 *idl)
#define DBG_ERROR(dbg_logger, format, args...)
int test7(int argc, char **argv)
int GWEN_IdList64_AddTests(GWEN_TEST_MODULE *mod)
GWEN_IDLIST64 * GWEN_IdList64_LazyCopy(GWEN_IDLIST64 *oldList)
int test4(int argc, char **argv)
int test11(int argc, char **argv)
uint64_t GWEN_IdList64_Iterator_GetNextId(GWEN_IDLIST64_ITERATOR *it)
#define GWEN_ERROR_INTERNAL
GWEN_TEST_MODULE * GWEN_Test_Module_AddModule(GWEN_TEST_MODULE *st, const char *tName, const char *tDescr)
struct GWEN_IDLIST64_ITERATOR GWEN_IDLIST64_ITERATOR
int64_t GWEN_IdList64_AddId(GWEN_IDLIST64 *idl, uint64_t entry)
int GWEN_IdList64_ReverseSort(GWEN_IDLIST64 *idl)
const char * GWEN_Error_SimpleToString(int i)
Returns a (very) short string describing the given GWEN error code, or "Unknown error" for unknown co...