@@ -47,19 +47,50 @@ void utest_assert_buf(const char *a, const char *b, rt_size_t sz, rt_bool_t equa
4747 * @macro uassert_buf_not_equal if @a not equal to @b, not assert, means passing. buf type test.
4848 * @macro uassert_in_range if @value is in range of min and max, not assert, means passing.
4949 * @macro uassert_not_in_range if @value is not in range of min and max, not assert, means passing.
50- *
51- */
50+ * @macro uassert_float_equal if @a equal to @b, not assert, means passing. Float type test.
51+ * @macro uassert_float_not_equal if @a not equal to @b, not assert, means passing. Float type test.
52+ * @macro uassert_value_less if @a less than @b, not assert, means passing.
53+ * @macro uassert_value_less_equal if @a less than or equal to @b, not assert, means passing.
54+ * @macro uassert_value_greater if @a greater than @b, not assert, means passing.
55+ * @macro uassert_value_greater_equal if @a greater than or equal to @b, not assert, means passing.
56+ * @macro uassert_ptr_equal if @a equal to @b, not assert, means passing. Pointer type test.
57+ * @macro uassert_ptr_not_equal if @a not equal to @b, not assert, means passing. Pointer type test.
58+ */
5259#define uassert_true (value ) __utest_assert(value, "(" #value ") is false")
5360#define uassert_false (value ) __utest_assert(!(value), "(" #value ") is true")
5461
5562#define uassert_null (value ) __utest_assert((const char *)(value) == RT_NULL, "(" #value ") is not null")
5663#define uassert_not_null (value ) __utest_assert((const char *)(value) != RT_NULL, "(" #value ") is null")
5764
58- #define uassert_in_range (value , min , max ) __utest_assert(((value >= min) && (value <= max)), "(" #value ") not in range("#min","#max")")
59- #define uassert_not_in_range (value , min , max ) __utest_assert(!((value >= min) && (value <= max)), "(" #value ") in range("#min","#max")")
60-
61- #define uassert_float_equal (a , b ) uassert_in_range(a, ((double)b - 0.0001), ((double)b + 0.0001))
62- #define uassert_float_not_equal (a , b ) uassert_not_in_range(a, ((double)b - 0.0001), ((double)b + 0.0001))
65+ #define uassert_in_range (value , min , max ) \
66+ do { \
67+ double _value = (value); \
68+ double _min = (min); \
69+ double _max = (max); \
70+ __utest_assert((_value >= _min) && (_value <= _max), "(" #value ") not in range("#min","#max")"); \
71+ } while(0)
72+
73+ #define uassert_not_in_range (value , min , max ) \
74+ do { \
75+ double _value = (value); \
76+ double _min = (min); \
77+ double _max = (max); \
78+ __utest_assert((_value < _min) || (_value > _max), "(" #value ") in range("#min","#max")"); \
79+ } while(0)
80+
81+ #define uassert_float_equal (a , b ) \
82+ do { \
83+ double _a = (a); \
84+ double _b = (b); \
85+ uassert_in_range(_a, ((double)_b - 0.0001), ((double)_b + 0.0001)); \
86+ } while(0)
87+
88+ #define uassert_float_not_equal (a , b ) \
89+ do { \
90+ double _a = (a); \
91+ double _b = (b); \
92+ uassert_not_in_range(_a, ((double)_b - 0.0001), ((double)_b + 0.0001)); \
93+ } while(0)
6394
6495#define uassert_int_equal (a , b ) __uassert_value_op(a, b, ==)
6596#define uassert_int_not_equal (a , b ) __uassert_value_op(a, b, !=)
0 commit comments