diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2012-11-17 16:57:30 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2012-11-17 16:57:30 +0000 |
commit | f2499612c5594944d3e0891259859668d35c85b2 (patch) | |
tree | 0672f579db91cfaca7a2935a86991fa67b5aae59 /tinytest/tinytest.h | |
parent | 429e46051dba814e7d6c74368eb1bba550222cbe (diff) | |
download | libconfig-f2499612c5594944d3e0891259859668d35c85b2.tar.gz |
Imported Upstream version 1.4.9upstream/1.4.9
Diffstat (limited to '')
-rw-r--r-- | tinytest/tinytest.h | 109 |
1 files changed, 107 insertions, 2 deletions
diff --git a/tinytest/tinytest.h b/tinytest/tinytest.h index 29a95e8..dd6e32a 100644 --- a/tinytest/tinytest.h +++ b/tinytest/tinytest.h @@ -65,7 +65,8 @@ typedef enum { TT_OP_INT_EQ, TT_OP_INT_NE, TT_OP_INT_LT, TT_OP_INT_LE, TT_OP_DOUBLE_GT, TT_OP_DOUBLE_GE, TT_OP_STR_EQ, TT_OP_STR_NE, TT_OP_STR_LT, TT_OP_STR_LE, TT_OP_STR_GT, TT_OP_STR_GE, TT_OP_PTR_EQ, TT_OP_PTR_NE, TT_OP_TRUE, TT_OP_FALSE, - TT_OP_FILE_EQ, TT_OP_FILE_NE } tt_op_t; + TT_OP_FILE_EQ, TT_OP_FILE_NE, TT_OP_TXTFILE_EQ, + TT_OP_TXTFILE_NE } tt_op_t; typedef struct tt_val_t { @@ -101,13 +102,27 @@ extern void tt_expect_bool(const char *file, int line, const char *expr, extern void tt_fail(const char *file, int line, const char *message, ...); +extern tt_bool_t tt_file_exists(const char *file); + +#ifdef _MSC_VER + +extern void tt_test_int(const char *file, int line, const char *aexpr, + tt_op_t op, const char *bexpr, int a, int b, + tt_bool_t fatal); + +#define TT_TEST_INT_(A, OP, B, F) \ + tt_test_int(__FILE__, __LINE__, #A, (OP), #B, (A), (B), (F)) + +#else #define TT_TEST_INT_(A, OP, B, F) \ - tt_expect(__FILE__, __LINE__, #A, OP, #B, \ + tt_expect(__FILE__, __LINE__, #A, (OP), #B, \ (tt_val_t){ TT_VAL_INT, .value.int_val = (A) }, \ (tt_val_t){ TT_VAL_INT, .value.int_val = (B) }, \ (F)) +#endif + #define TT_EXPECT_INT_EQ(A, B) \ TT_TEST_INT_((A), TT_OP_INT_EQ, (B), TT_FALSE) @@ -144,12 +159,25 @@ extern void tt_fail(const char *file, int line, const char *message, ...); #define TT_ASSERT_INT_GE(A, B) \ TT_TEST_INT_((A), TT_OP_INT_GE, (B), TT_TRUE) +#ifdef _MSC_VER + +extern void tt_test_uint(const char *file, int line, const char *aexpr, + tt_op_t op, const char *bexpr, unsigned int a, + unsigned int b, tt_bool_t fatal); + +#define TT_TEST_UINT_(A, OP, B, F) \ + tt_test_uint(__FILE__, __LINE__, #A, (OP), #B, (A), (B), (F)) + +#else + #define TT_TEST_UINT_(A, OP, B, F) \ tt_expect(__FILE__, __LINE__, #A, OP, #B, \ (tt_val_t){ TT_VAL_UINT, .value.uint_val = (A) }, \ (tt_val_t){ TT_VAL_UINT, .value.uint_val = (B) }, \ (F)) +#endif + #define TT_EXPECT_UINT_EQ(A, B) \ TT_TEST_UINT_((A), TT_OP_UINT_EQ, (B), TT_FALSE) @@ -186,12 +214,25 @@ extern void tt_fail(const char *file, int line, const char *message, ...); #define TT_ASSERT_UINT_GE(A, B) \ TT_TEST_UINT_((A), TT_OP_UINT_GE, (B), TT_TRUE) +#ifdef _MSC_VER + +extern void tt_test_int64(const char *file, int line, const char *aexpr, + tt_op_t op, const char *bexpr, long long a, + long long b, tt_bool_t fatal); + +#define TT_TEST_INT64_(A, OP, B, F) \ + tt_test_int64(__FILE__, __LINE__, #A, (OP), #B, (A), (B), (F)) + +#else + #define TT_TEST_INT64_(A, OP, B, F) \ tt_expect(__FILE__, __LINE__, #A, OP, #B, \ (tt_val_t){ TT_VAL_INT64, .value.int64_val = (A) }, \ (tt_val_t){ TT_VAL_INT64, .value.int64_val = (B) }, \ (F)) +#endif + #define TT_EXPECT_INT64_EQ(A, B) \ TT_TEST_INT64_((A), TT_OP_INT64_EQ, (B), TT_FALSE) @@ -228,12 +269,26 @@ extern void tt_fail(const char *file, int line, const char *message, ...); #define TT_ASSERT_INT64_GE(A, B) \ TT_TEST_INT64_((A), TT_OP_INT64_GE, (B), TT_TRUE) +#ifdef _MSC_VER + +extern void tt_test_uint64(const char *file, int line, const char *aexpr, + tt_op_t op, const char *bexpr, + unsigned long long a, unsigned long long b, + tt_bool_t fatal); + +#define TT_TEST_UINT64_(A, OP, B, F) \ + tt_test_uint64(__FILE__, __LINE__, #A, (OP), #B, (A), (B), (F)) + +#else + #define TT_TEST_UINT64_(A, OP, B, F) \ tt_expect(__FILE__, __LINE__, #A, OP, #B, \ (tt_val_t){ TT_VAL_UINT64, .value.uint64_val = (A) }, \ (tt_val_t){ TT_VAL_UINT64, .value.uint64_val = (B) }, \ (F)) +#endif + #define TT_EXPECT_UINT64_EQ(A, B) \ TT_TEST_UINT64_((A), TT_OP_UINT64_EQ, (B), TT_FALSE) @@ -270,12 +325,25 @@ extern void tt_fail(const char *file, int line, const char *message, ...); #define TT_ASSERT_UINT64_GE(A, B) \ TT_TEST_UINT64_((A), TT_OP_UINT64_GE, (B), TT_TRUE) +#ifdef _MSC_VER + +extern void tt_test_double(const char *file, int line, const char *aexpr, + tt_op_t op, const char *bexpr, double a, + double b, tt_bool_t fatal); + +#define TT_TEST_DOUBLE_(A, OP, B, F) \ + tt_test_double(__FILE__, __LINE__, #A, (OP), #B, (A), (B), (F)) + +#else + #define TT_TEST_DOUBLE_(A, OP, B, F) \ tt_expect(__FILE__, __LINE__, #A, OP, #B, \ (tt_val_t){ TT_VAL_DOUBLE, .value.double_val = (A) }, \ (tt_val_t){ TT_VAL_DOUBLE, .value.double_val = (B) }, \ (F)) +#endif + #define TT_EXPECT_DOUBLE_EQ(A, B) \ TT_TEST_DOUBLE_((A), TT_OP_DOUBLE_EQ, (B), TT_FALSE) @@ -312,12 +380,25 @@ extern void tt_fail(const char *file, int line, const char *message, ...); #define TT_ASSERT_DOUBLE_GE(A, B) \ TT_TEST_DOUBLE_((A), TT_OP_DOUBLE_GE, (B), TT_TRUE) +#ifdef _MSC_VER + +extern void tt_test_str(const char *file, int line, const char *aexpr, + tt_op_t op, const char *bexpr, const char *a, + const char *b, tt_bool_t fatal); + +#define TT_TEST_STR_(A, OP, B, F) \ + tt_test_str(__FILE__, __LINE__, #A, (OP), #B, (A), (B), (F)) + +#else + #define TT_TEST_STR_(A, OP, B, F) \ tt_expect(__FILE__, __LINE__, #A, OP, #B, \ (tt_val_t){ TT_VAL_STR, .value.str_val = (A) }, \ (tt_val_t){ TT_VAL_STR, .value.str_val = (B) }, \ (F)) +#endif + #define TT_EXPECT_STR_EQ(A, B) \ TT_TEST_STR_((A), TT_OP_STR_EQ, (B), TT_FALSE) @@ -354,12 +435,25 @@ extern void tt_fail(const char *file, int line, const char *message, ...); #define TT_ASSERT_STR_GE(A, B) \ TT_TEST_STR_((A), TT_OP_STR_GE, (B), TT_TRUE) +#ifdef _MSC_VER + +extern void tt_test_ptr(const char *file, int line, const char *aexpr, + tt_op_t op, const char *bexpr, const void *a, + const void *b, tt_bool_t fatal); + +#define TT_TEST_PTR_(A, OP, B, F) \ + tt_test_ptr(__FILE__, __LINE__, #A, (OP), #B, (A), (B), (F)) + +#else + #define TT_TEST_PTR_(A, OP, B, F) \ tt_expect(__FILE__, __LINE__, #A, OP, #B, \ (tt_val_t){ TT_VAL_PTR, .value.ptr_val = (A) }, \ (tt_val_t){ TT_VAL_PTR, .value.ptr_val = (B) }, \ (F)) +#endif + #define TT_EXPECT_PTR_EQ(A, B) \ TT_TEST_PTR_((A), TT_OP_PTR_EQ, (B), TT_FALSE) @@ -408,6 +502,17 @@ extern void tt_fail(const char *file, int line, const char *message, ...); #define TT_ASSERT_FILE_NE(A, B) \ TT_TEST_STR_((A), TT_OP_FILE_NE, (B), TT_TRUE) +#define TT_EXPECT_TXTFILE_EQ(A, B) \ + TT_TEST_STR_((A), TT_OP_TXTFILE_EQ, (B), TT_FALSE) + +#define TT_ASSERT_TXTFILE_EQ(A, B) \ + TT_TEST_STR_((A), TT_OP_TXTFILE_EQ, (B), TT_TRUE) + +#define TT_EXPECT_TXTFILE_NE(A, B) \ + TT_TEST_STR_((A), TT_OP_TXTFILE_NE, (B), TT_FALSE) + +#define TT_ASSERT_TXTFILE_NE(A, B) \ + TT_TEST_STR_((A), TT_OP_TXTFILE_NE, (B), TT_TRUE) #define TT_FAIL(M, ...) \ tt_fail(__FILE__, __LINE__, (M), __VA_ARGS__) |