tests more consistent
[protos/libecoli.git] / lib / ecoli_test.h
index 1cebe95..201f497 100644 (file)
@@ -31,7 +31,9 @@
 #include <sys/queue.h>
 
 #include <ecoli_log.h>
-#include <ecoli_node.h>
+
+struct ec_node;
+enum ec_completed_type;
 
 // XXX check if already exists?
 #define EC_TEST_REGISTER(t)                                            \
@@ -77,15 +79,15 @@ int ec_test_check_parse(struct ec_node *node, int expected, ...);
        EC_LOG(EC_LOG_ERR, "%s:%d: error: " fmt "\n",                   \
                __FILE__, __LINE__, ##__VA_ARGS__);                     \
 
-/* XXX this is not an assert, it does not abort */
-#define EC_TEST_ASSERT_STR(cond, fmt, ...)                             \
-       do {                                                            \
-               if (!(cond))                                            \
-                       EC_TEST_ERR("assert failure: (" #cond ") " fmt, \
-                               ##__VA_ARGS__);                         \
-       } while (0)
-
-#define EC_TEST_ASSERT(cond) EC_TEST_ASSERT_STR(cond, "")
+#define EC_TEST_CHECK(cond, fmt, ...) ({                               \
+       int ret_ = 0;                                                   \
+       if (!(cond)) {                                                  \
+               EC_TEST_ERR("(" #cond ") is wrong. "                    \
+                       ##__VA_ARGS__);                                 \
+               ret_ = -1;                                              \
+       }                                                               \
+       ret_;                                                           \
+})
 
 /* node, input, [expected1, expected2, ...] */
 #define EC_TEST_CHECK_PARSE(node, args...) ({                          \
@@ -95,10 +97,18 @@ int ec_test_check_parse(struct ec_node *node, int expected, ...);
        ret_;                                                           \
 })
 
-int ec_test_check_complete(struct ec_node *node, ...);
+int ec_test_check_complete(struct ec_node *node,
+                       enum ec_completed_type type, ...);
 
 #define EC_TEST_CHECK_COMPLETE(node, args...) ({                       \
-       int ret_ = ec_test_check_complete(node, args);                  \
+       int ret_ = ec_test_check_complete(node, EC_COMP_FULL, args);    \
+       if (ret_)                                                       \
+               EC_TEST_ERR("complete test failed");                    \
+       ret_;                                                           \
+})
+
+#define EC_TEST_CHECK_COMPLETE_PARTIAL(node, args...) ({               \
+       int ret_ = ec_test_check_complete(node, EC_COMP_PARTIAL, args); \
        if (ret_)                                                       \
                EC_TEST_ERR("complete test failed");                    \
        ret_;                                                           \