// Minimal test scaffolding. No frameworks, no dependencies — the whole // point of this harness is that it runs anywhere gcc runs. #pragma once #include #include extern int g_tests_run; extern int g_tests_failed; #define CHECK(cond, ...) \ do { \ g_tests_run++; \ if (!(cond)) { \ g_tests_failed++; \ printf(" FAIL %s:%d: ", __FILE__, __LINE__); \ printf(__VA_ARGS__); \ printf("\n condition: %s\n", #cond); \ } \ } while (0) #define CHECK_EQ_U(actual, expected, ...) \ do { \ unsigned long long a_ = (unsigned long long)(actual); \ unsigned long long e_ = (unsigned long long)(expected); \ g_tests_run++; \ if (a_ != e_) { \ g_tests_failed++; \ printf(" FAIL %s:%d: ", __FILE__, __LINE__); \ printf(__VA_ARGS__); \ printf("\n expected %llu, got %llu\n", e_, a_); \ } \ } while (0) #define CHECK_NEAR(actual, expected, tol, ...) \ do { \ double a_ = (double)(actual); \ double e_ = (double)(expected); \ double d_ = a_ - e_; \ if (d_ < 0) d_ = -d_; \ g_tests_run++; \ if (!(d_ <= (double)(tol))) { \ g_tests_failed++; \ printf(" FAIL %s:%d: ", __FILE__, __LINE__); \ printf(__VA_ARGS__); \ printf("\n expected %.6f +/- %.6f, got %.6f\n", \ e_, (double)(tol), a_); \ } \ } while (0) #define SUITE(name) printf("[%s]\n", (name)) void test_rd03e_parse(void); void test_bmp280_compensate(void); void test_mems_level(void);