diff --git a/assert.h b/assert.h new file mode 100644 index 0000000..f8e9d05 --- /dev/null +++ b/assert.h @@ -0,0 +1,25 @@ +#pragma once + +#include <stdint.h> +#include <stdio.h> + +#define ASSERTold(expr) \ + do { \ + if (!(expr)) { \ + printf("ASSERTION FAILED: %s at %s:%d\n", #expr, __FILE__, \ + __LINE__); \ + while (1); \ + } \ + } while (0) + +#define ASSERT_EQ(expr, expected) \ + do { \ + uint64_t result = (expr); \ + if (result != (expected)) { \ + printf("ASSERTION FAILED: %s at %s:%d\n", #expr, __FILE__, \ + __LINE__); \ + printf("Expected: %lu, Got: %lu\n", (unsigned long)(expected), \ + (unsigned long)result); \ + while (1); \ + } \ + } while (0) diff --git a/main.c b/main.c index 29770df..0ed24e6 100644 --- a/main.c +++ b/main.c @@ -1,8 +1,10 @@ +#include "assert.h" #include <ch32fun.h> #include <rand.h> #include <rsa.h> #include <stdint.h> #include <stdio.h> +#include <string.h> #define LED_PIN PD6