1#include <lal/LALConfig.h>
6#include <lal/LALStdlib.h>
7#include <lal/LALValue.h>
8#include <lal/LALDict.h>
11#define UNUSED __attribute__ ((unused))
16#define CHAR_VALUE LAL_INT8_C(+111)
17#define INT2_VALUE LAL_INT8_C(-11111)
18#define INT4_VALUE LAL_INT8_C(-1111111111)
19#define INT8_VALUE LAL_INT8_C(-111111111111111111)
20#define UCHAR_VALUE LAL_UINT8_C(222)
21#define UINT2_VALUE LAL_UINT8_C(44444)
22#define UINT4_VALUE LAL_UINT8_C(3333333333)
23#define UINT8_VALUE LAL_UINT8_C(11111111111111111111)
24#define REAL4_VALUE 100.0
25#define REAL8_VALUE 1e100
26#define COMPLEX8_VALUE 3.0 + 4.0 * I
27#define COMPLEX16_VALUE 3e100 + 4e100 * I
45 if (!intdict || !floatdict || !complexdict || !blobdict || !strdict)
70 return err ? NULL : dict;
97 return err ? NULL : list;
119static int string_value_cmp(
const LALValue *value1,
const LALValue *value2,
void UNUSED *thunk)
124#define COMPARE(v, TYPE) (v == TYPE ## _VALUE)
127 fprintf(stderr, "Testing %s... ", #TYPE); \
128 entry = XLALDictLookup(dict, #TYPE); \
129 orig = XLALDictEntryGetValue(entry); \
130 size = XLALValueGetSize(orig); \
131 copy = XLALValueRealloc(copy, size); \
132 copy = XLALValueCopy(copy, orig); \
133 if (!XLALValueEqual(copy, orig)) { \
134 fprintf(stderr, "failed:"); \
135 XLALValuePrint(copy, 2); \
136 fprintf(stderr, " != "); \
137 XLALValuePrint(orig, 2); \
138 fprintf(stderr, "\n"); \
141 if (!COMPARE(XLALValueGet ## TYPE(copy), TYPE)) { \
142 fprintf(stderr, "failed: incorrect value\n"); \
145 XLALDictRemove(dict, #TYPE); \
146 fprintf(stderr, "passed\n");
149 fprintf(stderr, "Testing %s Pop... ", #TYPE); \
150 if (!COMPARE(XLALDictPop ## TYPE ## Value(dict2, #TYPE), TYPE)) { \
151 fprintf(stderr, "failed: incorrect value\n"); \
154 fprintf(stderr, "passed\n");
164 const LALValue *orig;
165 LALValue *copy = NULL;
207#define COMPARE(v, TYPE) (!memcmp(blob = v, BLOB_VALUE, sizeof(BLOB_VALUE)))
214#define COMPARE(v, TYPE) (!strcmp(v, String_VALUE))
217#define COMPARE(v, TYPE) (!strcmp(str = v, String_VALUE))
LALList * XLALDictKeys(const LALDict *dict)
int XLALDictUpdate(LALDict *dst, const LALDict *src)
LALDict * XLALDictMerge(const LALDict *dict1, const LALDict *dict2)
void XLALDestroyDict(LALDict *dict)
LALDict * XLALDictDuplicate(const LALDict *orig)
LALDict * XLALCreateDict(void)
int XLALDictInsertBLOBValue(LALDict *dict, const char *key, const void *blob, size_t size)
size_t XLALDictSize(const LALDict *dict)
int XLALDictInsertStringValue(LALDict *dict, const char *key, const char *string)
int XLALDictInsertUINT4Value(LALDict *dict, const char *key, UINT4 value)
int XLALDictInsertUINT2Value(LALDict *dict, const char *key, UINT2 value)
int XLALDictInsertINT2Value(LALDict *dict, const char *key, INT2 value)
int XLALDictInsertINT8Value(LALDict *dict, const char *key, INT8 value)
int XLALDictInsertCOMPLEX16Value(LALDict *dict, const char *key, COMPLEX16 value)
int XLALDictInsertINT4Value(LALDict *dict, const char *key, INT4 value)
int XLALDictInsertREAL8Value(LALDict *dict, const char *key, REAL8 value)
int XLALDictInsertCOMPLEX8Value(LALDict *dict, const char *key, COMPLEX8 value)
int XLALDictInsertUINT8Value(LALDict *dict, const char *key, UINT8 value)
int XLALDictInsertUCHARValue(LALDict *dict, const char *key, UCHAR value)
int XLALDictInsertREAL4Value(LALDict *dict, const char *key, REAL4 value)
int XLALDictInsertCHARValue(LALDict *dict, const char *key, CHAR value)
int XLALListReverse(LALList *list)
size_t XLALListSize(const LALList *list)
LALList * XLALCreateList(void)
void XLALListIterInit(LALListIter *iter, LALList *list)
int XLALListSort(LALList *list, int(*cmp)(const LALValue *, const LALValue *, void *), void *thunk)
int XLALListAddStringValue(LALList *list, const char *string)
const LALValue * XLALListItemGetValue(const LALListItem *item)
LALListItem * XLALListIterNext(LALListIter *iter)
void XLALDestroyList(LALList *list)
void LALCheckMemoryLeaks(void)
int XLALValueEqual(const LALValue *value1, const LALValue *value2)
void XLALDestroyValue(LALValue *value)
const char * XLALValueGetString(const LALValue *value)
static int lists_are_equal(LALList *list1, LALList *list2)
static LALDict * create_dict(void)
static LALList * create_list(void)
static int string_value_cmp(const LALValue *value1, const LALValue *value2, void UNUSED *thunk)
unsigned char UCHAR
One-byte unsigned integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint64_t UINT8
Eight-byte unsigned integer; on some platforms this is equivalent to unsigned long int instead.
double complex COMPLEX16
Double-precision floating-point complex number (16 bytes total)
double REAL8
Double precision real floating-point number (8 bytes).
int16_t INT2
Two-byte signed integer.
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
uint16_t UINT2
Two-byte unsigned integer.
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
float complex COMPLEX8
Single-precision floating-point complex number (8 bytes total)
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).