diff options
Diffstat (limited to 'src/test/test.h')
-rw-r--r-- | src/test/test.h | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/src/test/test.h b/src/test/test.h index b9e4d5bdb4..e618ce1224 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -1,6 +1,6 @@ /* Copyright (c) 2001-2003, Roger Dingledine. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. - * Copyright (c) 2007-2013, The Tor Project, Inc. */ + * Copyright (c) 2007-2016, The Tor Project, Inc. */ /* See LICENSE for licensing information */ #ifndef TOR_TEST_H @@ -22,25 +22,6 @@ #define PRETTY_FUNCTION "" #endif -#define test_fail_msg(msg) TT_DIE((msg)) - -#define test_fail() test_fail_msg("Assertion failed.") - -#define test_assert(expr) tt_assert(expr) - -#define test_eq(expr1, expr2) tt_int_op((expr1), ==, (expr2)) -#define test_eq_ptr(expr1, expr2) tt_ptr_op((expr1), ==, (expr2)) -#define test_neq(expr1, expr2) tt_int_op((expr1), !=, (expr2)) -#define test_neq_ptr(expr1, expr2) tt_ptr_op((expr1), !=, (expr2)) -#define test_streq(expr1, expr2) tt_str_op((expr1), ==, (expr2)) -#define test_strneq(expr1, expr2) tt_str_op((expr1), !=, (expr2)) - -#define test_mem_op(expr1, op, expr2, len) \ - tt_mem_op((expr1), op, (expr2), (len)) - -#define test_memeq(expr1, expr2, len) test_mem_op((expr1), ==, (expr2), len) -#define test_memneq(expr1, expr2, len) test_mem_op((expr1), !=, (expr2), len) - /* As test_mem_op, but decodes 'hex' before comparing. There must be a * local char* variable called mem_op_hex_tmp for this to work. */ #define test_mem_op_hex(expr1, op, hex) \ @@ -50,15 +31,24 @@ mem_op_hex_tmp = tor_malloc(length/2); \ tor_assert((length&1)==0); \ base16_decode(mem_op_hex_tmp, length/2, hex, length); \ - test_mem_op(expr1, op, mem_op_hex_tmp, length/2); \ + tt_mem_op(expr1, op, mem_op_hex_tmp, length/2); \ STMT_END -#define test_memeq_hex(expr1, hex) test_mem_op_hex(expr1, ==, hex) +#define test_memeq_hex(expr1, hex) test_mem_op_hex(expr1, OP_EQ, hex) #define tt_double_op(a,op,b) \ - tt_assert_test_type(a,b,#a" "#op" "#b,double,(val1_ op val2_),"%f", \ + tt_assert_test_type(a,b,#a" "#op" "#b,double,(val1_ op val2_),"%g", \ TT_EXIT_TEST_FUNCTION) +/* Declare "double equal" in a sneaky way, so compiler won't complain about + * comparing floats with == or !=. Of course, only do this if you know what + * you're doing. */ +#define tt_double_eq(a,b) \ + STMT_BEGIN \ + tt_double_op((a), >=, (b)); \ + tt_double_op((a), <=, (b)); \ + STMT_END + #ifdef _MSC_VER #define U64_PRINTF_TYPE uint64_t #define I64_PRINTF_TYPE int64_t @@ -85,9 +75,6 @@ const char *get_fname(const char *name); crypto_pk_t *pk_generate(int idx); -void legacy_test_helper(void *data); -extern const struct testcase_setup_t legacy_setup; - #define US2_CONCAT_2__(a, b) a ## __ ## b #define US_CONCAT_2__(a, b) a ## _ ## b #define US_CONCAT_3__(a, b, c) a ## _ ## b ## _ ## c @@ -180,5 +167,7 @@ extern const struct testcase_setup_t legacy_setup; #define NS_MOCK(name) MOCK(name, NS(name)) #define NS_UNMOCK(name) UNMOCK(name) +extern const struct testcase_setup_t passthrough_setup; + #endif |