Skip to content

Commit 1d2e902

Browse files
committed
Removal of hardcoded YT__Arg field count
This field count is used to get number of YT__Arg arguments passed to the `YT__add_callrecord` function (the `n` parameter in the function).
1 parent d925ca4 commit 1d2e902

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

yukti.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ typedef struct YT__Arg {
243243
uintptr_t val; // A type large enough to hold both integers & addresses
244244
} YT__Arg;
245245

246+
#define YT__ARG_FIELDS_COUNT 2
247+
246248
#define YT__RECORD_CALL_X(...) YT__FCALL_WRAP_ARGS_X (YT_V, ##__VA_ARGS__)
247249

248250
#define YT_V(v) \
@@ -469,30 +471,33 @@ static void YT__free_testRecord (YT__TestRecord* trecord)
469471
#else
470472
#define YT_IN_SEQUENCE(n) for (int i = 0; i < (n); i++)
471473

472-
#define YT_MUST_NEVER_CALL(f, ...) \
473-
do { \
474-
YT__current_testrecord->total_exp_count++; \
475-
YT__add_callrecord (&YT__neverCallExceptationsListHead, __LINE__, __FILE__, \
476-
YT__COUNT_ARGS (__VA_ARGS__) / 2, #f, ##__VA_ARGS__); \
474+
#define YT_MUST_NEVER_CALL(f, ...) \
475+
do { \
476+
YT__current_testrecord->total_exp_count++; \
477+
YT__add_callrecord (&YT__neverCallExceptationsListHead, __LINE__, __FILE__, \
478+
YT__COUNT_ARGS (__VA_ARGS__) / YT__ARG_FIELDS_COUNT, #f, \
479+
##__VA_ARGS__); \
477480
} while (0)
478481

479-
#define YT_MUST_CALL_IN_ORDER(f, ...) \
480-
do { \
481-
YT__current_testrecord->total_exp_count++; \
482-
YT__add_callrecord (&YT__orderedExceptationListHead, __LINE__, __FILE__, \
483-
YT__COUNT_ARGS (__VA_ARGS__) / 2, #f, ##__VA_ARGS__); \
482+
#define YT_MUST_CALL_IN_ORDER(f, ...) \
483+
do { \
484+
YT__current_testrecord->total_exp_count++; \
485+
YT__add_callrecord (&YT__orderedExceptationListHead, __LINE__, __FILE__, \
486+
YT__COUNT_ARGS (__VA_ARGS__) / YT__ARG_FIELDS_COUNT, #f, \
487+
##__VA_ARGS__); \
484488
} while (0)
485489

486490
#define YT_MUST_CALL_IN_ORDER_ATLEAST_TIMES(n, f, ...) \
487491
for (int i = n; i; i--) { \
488492
YT_MUST_CALL_IN_ORDER (f, ##__VA_ARGS__); \
489493
}
490494

491-
#define YT_MUST_CALL_ANY_ORDER(f, ...) \
492-
do { \
493-
YT__current_testrecord->total_exp_count++; \
494-
YT__add_callrecord (&YT__globalExceptationListHead, __LINE__, __FILE__, \
495-
YT__COUNT_ARGS (__VA_ARGS__) / 2, #f, ##__VA_ARGS__); \
495+
#define YT_MUST_CALL_ANY_ORDER(f, ...) \
496+
do { \
497+
YT__current_testrecord->total_exp_count++; \
498+
YT__add_callrecord (&YT__globalExceptationListHead, __LINE__, __FILE__, \
499+
YT__COUNT_ARGS (__VA_ARGS__) / YT__ARG_FIELDS_COUNT, #f, \
500+
##__VA_ARGS__); \
496501
} while (0)
497502

498503
#define YT_MUST_CALL_ANY_ORDER_ATLEAST_TIMES(n, f, ...) \

0 commit comments

Comments
 (0)