Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-3a66518
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ValueTest.c File Reference

Prototypes

static LALDict * create_dict (void)
 
static LALList * create_list (void)
 
static int lists_are_equal (LALList *list1, LALList *list2)
 
static int string_value_cmp (const LALValue *value1, const LALValue *value2, void UNUSED *thunk)
 
int main (void)
 

Go to the source code of this file.

Macros

#define CHAR_VALUE   LAL_INT8_C(+111)
 
#define INT2_VALUE   LAL_INT8_C(-11111)
 
#define INT4_VALUE   LAL_INT8_C(-1111111111)
 
#define INT8_VALUE   LAL_INT8_C(-111111111111111111)
 
#define UCHAR_VALUE   LAL_UINT8_C(222)
 
#define UINT2_VALUE   LAL_UINT8_C(44444)
 
#define UINT4_VALUE   LAL_UINT8_C(3333333333)
 
#define UINT8_VALUE   LAL_UINT8_C(11111111111111111111)
 
#define REAL4_VALUE   100.0
 
#define REAL8_VALUE   1e100
 
#define COMPLEX8_VALUE   3.0 + 4.0 * I
 
#define COMPLEX16_VALUE   3e100 + 4e100 * I
 
#define COMPARE(v, TYPE)   (v == TYPE ## _VALUE)
 
#define TEST(TYPE)
 
#define TEST2(TYPE)
 
#define COMPARE(v, TYPE)   (!memcmp(blob = v, BLOB_VALUE, sizeof(BLOB_VALUE)))
 
#define COMPARE(v, TYPE)   (!strcmp(v, String_VALUE))
 
#define COMPARE(v, TYPE)   (!strcmp(str = v, String_VALUE))
 

Variables

char BLOB_VALUE [5] = {'\x68', '\x65', '\x6c', '\x6c', '\x6f'}
 
char String_VALUE [] = "world"
 

Macro Definition Documentation

◆ CHAR_VALUE

#define CHAR_VALUE   LAL_INT8_C(+111)

Definition at line 16 of file ValueTest.c.

◆ INT2_VALUE

#define INT2_VALUE   LAL_INT8_C(-11111)

Definition at line 17 of file ValueTest.c.

◆ INT4_VALUE

#define INT4_VALUE   LAL_INT8_C(-1111111111)

Definition at line 18 of file ValueTest.c.

◆ INT8_VALUE

#define INT8_VALUE   LAL_INT8_C(-111111111111111111)

Definition at line 19 of file ValueTest.c.

◆ UCHAR_VALUE

#define UCHAR_VALUE   LAL_UINT8_C(222)

Definition at line 20 of file ValueTest.c.

◆ UINT2_VALUE

#define UINT2_VALUE   LAL_UINT8_C(44444)

Definition at line 21 of file ValueTest.c.

◆ UINT4_VALUE

#define UINT4_VALUE   LAL_UINT8_C(3333333333)

Definition at line 22 of file ValueTest.c.

◆ UINT8_VALUE

#define UINT8_VALUE   LAL_UINT8_C(11111111111111111111)

Definition at line 23 of file ValueTest.c.

◆ REAL4_VALUE

#define REAL4_VALUE   100.0

Definition at line 24 of file ValueTest.c.

◆ REAL8_VALUE

#define REAL8_VALUE   1e100

Definition at line 25 of file ValueTest.c.

◆ COMPLEX8_VALUE

#define COMPLEX8_VALUE   3.0 + 4.0 * I

Definition at line 26 of file ValueTest.c.

◆ COMPLEX16_VALUE

#define COMPLEX16_VALUE   3e100 + 4e100 * I

Definition at line 27 of file ValueTest.c.

◆ COMPARE [1/4]

#define COMPARE (   v,
  TYPE 
)    (v == TYPE ## _VALUE)

Definition at line 124 of file ValueTest.c.

◆ TEST

#define TEST (   TYPE)
Value:
fprintf(stderr, "Testing %s... ", #TYPE); \
entry = XLALDictLookup(dict, #TYPE); \
orig = XLALDictEntryGetValue(entry); \
size = XLALValueGetSize(orig); \
copy = XLALValueRealloc(copy, size); \
copy = XLALValueCopy(copy, orig); \
if (!XLALValueEqual(copy, orig)) { \
fprintf(stderr, "failed:"); \
XLALValuePrint(copy, 2); \
fprintf(stderr, " != "); \
XLALValuePrint(orig, 2); \
fprintf(stderr, "\n"); \
return 1; \
} \
if (!COMPARE(XLALValueGet ## TYPE(copy), TYPE)) { \
fprintf(stderr, "failed: incorrect value\n"); \
return 1; \
} \
XLALDictRemove(dict, #TYPE); \
fprintf(stderr, "passed\n");
#define TYPE
LALDictEntry * XLALDictLookup(const LALDict *dict, const char *key)
Definition: LALDict.c:305
const LALValue * XLALDictEntryGetValue(const LALDictEntry *entry)
Definition: LALDict.c:120
LALValue * XLALValueRealloc(LALValue *value, size_t size)
Definition: LALValue.c:40
LALValue * XLALValueCopy(LALValue *copy, const LALValue *orig)
Definition: LALValue.c:60
int XLALValueEqual(const LALValue *value1, const LALValue *value2)
Definition: LALValue.c:203
size_t XLALValueGetSize(const LALValue *value)
Definition: LALValue.c:185
#define fprintf
#define COMPARE(v, TYPE)
Definition: ValueTest.c:124

Definition at line 126 of file ValueTest.c.

◆ TEST2

#define TEST2 (   TYPE)
Value:
fprintf(stderr, "Testing %s Pop... ", #TYPE); \
if (!COMPARE(XLALDictPop ## TYPE ## Value(dict2, #TYPE), TYPE)) { \
fprintf(stderr, "failed: incorrect value\n"); \
return 1; \
} \
fprintf(stderr, "passed\n");
LALDictEntry * XLALDictPop(LALDict *dict, const char *key)
Definition: LALDict.c:314

Definition at line 148 of file ValueTest.c.

◆ COMPARE [2/4]

#define COMPARE (   v,
  TYPE 
)    (!memcmp(blob = v, BLOB_VALUE, sizeof(BLOB_VALUE)))

Definition at line 124 of file ValueTest.c.

◆ COMPARE [3/4]

#define COMPARE (   v,
  TYPE 
)    (!strcmp(v, String_VALUE))

Definition at line 124 of file ValueTest.c.

◆ COMPARE [4/4]

#define COMPARE (   v,
  TYPE 
)    (!strcmp(str = v, String_VALUE))

Definition at line 124 of file ValueTest.c.

Function Documentation

◆ create_dict()

static LALDict * create_dict ( void  )
static

Definition at line 31 of file ValueTest.c.

◆ create_list()

static LALList * create_list ( void  )
static

Definition at line 73 of file ValueTest.c.

◆ lists_are_equal()

static int lists_are_equal ( LALList *  list1,
LALList *  list2 
)
static

Definition at line 100 of file ValueTest.c.

◆ string_value_cmp()

static int string_value_cmp ( const LALValue *  value1,
const LALValue *  value2,
void UNUSED *  thunk 
)
static

Definition at line 119 of file ValueTest.c.

◆ main()

int main ( void  )

Definition at line 156 of file ValueTest.c.

Variable Documentation

◆ BLOB_VALUE

char BLOB_VALUE[5] = {'\x68', '\x65', '\x6c', '\x6c', '\x6f'}

Definition at line 28 of file ValueTest.c.

◆ String_VALUE

char String_VALUE[] = "world"

Definition at line 29 of file ValueTest.c.