Assert file
This commit is contained in:
parent
120a61eca7
commit
52857830ac
2 changed files with 27 additions and 0 deletions
25
assert.h
Normal file
25
assert.h
Normal file
|
@ -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)
|
2
main.c
2
main.c
|
@ -1,8 +1,10 @@
|
||||||
|
#include "assert.h"
|
||||||
#include <ch32fun.h>
|
#include <ch32fun.h>
|
||||||
#include <rand.h>
|
#include <rand.h>
|
||||||
#include <rsa.h>
|
#include <rsa.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define LED_PIN PD6
|
#define LED_PIN PD6
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue