Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
highlevel: add more tests, fix old tests, fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
kodebach committed Nov 11, 2018
1 parent d9618f7 commit 937139b
Show file tree
Hide file tree
Showing 4 changed files with 415 additions and 115 deletions.
3 changes: 2 additions & 1 deletion src/libs/highlevel/elektra.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
static void defaultFatalErrorHandler (ElektraError * error)
{
ELEKTRA_LOG_DEBUG ("FATAL ERROR [%d]: %s", error->code, error->description);
ElektraErrorCode code = error->code;
elektraFree (error);
exit (error->code);
exit (code);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/libs/highlevel/elektra_array_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Key * elektraFindArrayElementKey (Elektra * elektra, const char * name, size_t i
return NULL;
}

if (!elektra->enforceType && type != NULL)
if (elektra->enforceType && type != NULL)
{
const char * actualType = keyString (keyGetMeta (resultKey, "type"));
if (strcmp (actualType, type) != 0)
Expand Down Expand Up @@ -128,7 +128,7 @@ void elektraSetArrayElementValue (Elektra * elektra, const char * name, size_t i

#define ELEKTRA_GET_ARRAY_ELEMENT_VALUE(KEY_TO_VALUE, KDB_TYPE, elektra, keyname, index, result) \
const Key * key = elektraFindArrayElementKey (elektra, keyname, index, KDB_TYPE); \
if (!KEY_TO_VALUE (key, &result)) \
if (key == NULL || !KEY_TO_VALUE (key, &result)) \
{ \
elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE, keyString (key), NULL)); \
return 0; \
Expand Down
4 changes: 2 additions & 2 deletions src/libs/highlevel/elektra_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Key * elektraFindKey (Elektra * elektra, const char * name, KDBType type)
return NULL;
}

if (!elektra->enforceType && type != NULL)
if (elektra->enforceType && type != NULL)
{
const char * actualType = keyString (keyGetMeta (resultKey, "type"));
if (strcmp (actualType, type) != 0)
Expand Down Expand Up @@ -103,7 +103,7 @@ void elektraSetValue (Elektra * elektra, const char * name, const char * value,

#define ELEKTRA_GET_VALUE(KEY_TO_VALUE, KDB_TYPE, elektra, keyname, result) \
const Key * key = elektraFindKey (elektra, keyname, KDB_TYPE); \
if (!KEY_TO_VALUE (key, &result)) \
if (key == NULL || !KEY_TO_VALUE (key, &result)) \
{ \
elektraFatalError (elektra, elektraErrorConversionFromString (KDB_TYPE, keyString (key), NULL)); \
result = 0; \
Expand Down
Loading

0 comments on commit 937139b

Please sign in to comment.