You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

49 lines
1.3 KiB

#include "u_async.h"
#include <stdio.h>
/* Test statistics */
static struct {
int tests_run;
int tests_passed;
int tests_failed;
/* Timer statistics */
int timer_callbacks;
int timer_cancellations;
int immediate_timeouts;
/* Socket statistics */
int socket_events;
int socket_errors;
/* Error statistics */
int memory_allocation_errors;
int invalid_parameter_errors;
int race_condition_errors;
} test_stats = {0};
/* Timer callback for testing */
static void test_timer_callback(void* arg) {
test_stats.timer_callbacks++;
printf("Timer callback fired. Total callbacks: %d\n", test_stats.timer_callbacks);
}
int main() {
printf("Before any tests: immediate_timeouts = %d\n", test_stats.immediate_timeouts);
uasync_t* ua = uasync_create();
/* Set 5 immediate timeouts */
for (int i = 0; i < 5; i++) {
void* timer = uasync_set_timeout(ua, 0, NULL, test_timer_callback);
}
printf("After setting 5 immediate timeouts, before poll: immediate_timeouts = %d\n", test_stats.immediate_timeouts);
uasync_poll(ua, 1);
printf("After poll: immediate_timeouts = %d\n", test_stats.immediate_timeouts);
uasync_destroy(ua, 0);
return 0;
}