#define CCUNITASSERT_H
#include <ccunit/CCUnitConfig.h>
-#include <stdbool.h>
-
-typedef enum CCUnitAssertFailed_t {
- ccunit_failed_assertTest = 1,
- ccunit_failed_assertTestInt,
- ccunit_failed_assertTestUInt,
- ccunit_failed_assertTestStr,
-} CCUnitAssertFailed_t;
+/**
+ * Check for a failed general assertion.
+ * @param file file name.
+ * @param line line number.
+ * @param cond assert condition.
+ * @param condstr assert condition as string.
+ */
extern void ccunit_assert (const char* file, unsigned int line,
bool cond, const char* condstr);
+/**
+ * Check for a failed assertion.
+ * @param file file name.
+ * @param line line number.
+ * @param cond assert condition.
+ * @param condstr assert condition as string.
+ * @param vfmt tested value format string for sprintf.
+ * @param ... expect value and actual value.
+ */
extern void ccunit_assert_test (const char* file, unsigned int line,
bool cond, const char* condstr,
const char* vfmt, ...);
+/**
+ * Check for a failed general assertion.
+ * @param COND assert condition.
+ */
#define CCUNIT_ASSERT(COND) ccunit_assert (__FILE__, __LINE__, COND, #COND)
+/**
+ * Check for a failed general assertion.
+ * @param VFMT format string for expect/actual value.
+ * @param TYP type of expect/actual value.
+ * @param EXPECT expect value.
+ * @param OP test operator.
+ * @param ACTUAL actual value.
+ */
#define CCUNIT_ASSERT_TEST(VFMT, TYP, EXPECT, OP, ACTUAL) \
ccunit_assert_test (__FILE__, __LINE__, (EXPECT) OP (ACTUAL), \
(#EXPECT " " #OP " " #ACTUAL), \
*/
#include <ccunit/CCUnitList.h>
+/**
+ * List Cell class.
+ */
typedef struct CCUnitListCell
{
- struct CCUnitListCell* next;
- void* contents;
+ struct CCUnitListCell* next; /**< next cell pointer */
+ void* contents; /**< list content object */
} CCUnitListCell;
+/**
+ * Initialize List object.
+ * @param list list object to initialize.
+ * @return initialized list object.
+ */
CCUnitList* ccunit_initList (CCUnitList* list)
{
list->length = 0;
return list;
}
+/**
+ * create new list object.
+ * @return new list object.
+ */
inline CCUnitList* ccunit_newList ()
{
CCUnitList* newList = calloc (1, sizeof (*newList));
return newList;
}
+/**
+ * create new list cell object.
+ * @return new list cell object.
+ */
static inline CCUnitListCell* ccunit_newListCell ()
{
return calloc (1, sizeof (CCUnitListCell));
}
+/**
+ * delete list cell object.
+ * @param cell deleting cell.
+ */
static inline void ccunit_deleteListCell (CCUnitListCell* cell)
{
safe_free (cell);
#endif
#include <stdbool.h>
+/**
+ * list container.
+ */
typedef struct CCUnitList
{
- struct CCUnitListCell* head;
- struct CCUnitListCell** tailp;
- size_t length;
- bool isAllocated;
+ struct CCUnitListCell* head; /**< first cell of a linked list */
+ struct CCUnitListCell** tailp; /**< address of pointer to last cell*/
+ size_t length; /**< size of linked list */
+ bool isAllocated; /**< flag of allocated object */
} CCUnitList;
+/**
+ * list iterator.
+ */
typedef struct CCUnitListIterator
{
- struct CCUnitListCell* current;
- bool isAllocated;
+ struct CCUnitListCell* current; /**< current list cell */
+ bool isAllocated; /**< flag ob allocated object */
} CCUnitListIterator;
+/**
+ * Create new list object.
+ * @return new list object.
+ */
extern inline CCUnitList* ccunit_newList ();
+
+/**
+ * Add element to list object.
+ * @param list List object.
+ * @param contents A pointer to an object to register in the list.
+ */
extern void ccunit_addList (CCUnitList* list, void* contents);
+
+/**
+ * Initialize list object.
+ * @param list initializing list.
+ * @return initialized list.
+ */
extern CCUnitList* ccunit_initList (CCUnitList* list);
+
+/**
+ * Delete list object.
+ *
+ * @param list Deleting list.
+ * @param deleteContents A pointer to the function which the object
+ * registered in the list is deleted from.
+ */
extern void ccunit_deleteList (CCUnitList* list, void (*deleteContents)(void*));
+/**
+ * create new list iterator.
+ *
+ * @param list An owner list of iterator.
+ * @return New iterator.
+ */
extern CCUnitListIterator* ccunit_newListIterator (const struct CCUnitList* list);
+
+/**
+ * initialize list iterator.
+ * @param list An owner list of iterator.
+ * @param it Iterator to initialize.
+ * @return Initialized iterator.
+ */
extern inline
CCUnitListIterator* ccunit_initListIterator (const struct CCUnitList* list,
struct CCUnitListIterator* it);
+
+/**
+ * delete list iterator.
+ *
+ * @param it iterator to delete.
+ */
extern inline void ccunit_deleteListIterator (struct CCUnitListIterator* it);
+
+/**
+ * Get next element.
+ * @param it An Iterator.
+ * @return pointer to next element object.
+ */
extern void* ccunit_nextListIterator (struct CCUnitListIterator* it);
+
+/**
+ * Check is there next element of iterator.
+ * @param it An iterator.
+ * @return true if there is next element, or false.
+ */
extern bool ccunit_hasNextListIterator (struct CCUnitListIterator* it);
#endif