Add timespec -- add tests for it too.
This commit is contained in:
@ -1,26 +1,34 @@
|
||||
#ifndef __TEST_H
|
||||
#define __TEST_H
|
||||
|
||||
#pragma once
|
||||
#include "mgos.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "frozen/frozen.h"
|
||||
#include "mgos_mock.h"
|
||||
#include "main.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern int test_failures;
|
||||
extern int assert_count;
|
||||
extern uint32_t s_test_count_fail, s_test_count_total;
|
||||
|
||||
#define ASSERT(expr, errstr) \
|
||||
do { \
|
||||
if (!(expr)) { \
|
||||
LOG(LL_ERROR, ("ASSERT FAIL: "errstr)); \
|
||||
test_failures++; \
|
||||
} \
|
||||
assert_count++; \
|
||||
#define ASSERT(expr, msg) \
|
||||
do { \
|
||||
s_test_count_total++; \
|
||||
if (!(expr)) { \
|
||||
LOG(LL_ERROR, ("TEST FAILURE line=%d expr='%s' msg='%s'", __LINE__, #expr, msg)); \
|
||||
s_test_count_fail++; \
|
||||
} else { \
|
||||
LOG(LL_INFO, ("TEST PASS line=%d expr='%s' msg='%s'", __LINE__, #expr, msg)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RUN_TEST(test) \
|
||||
do { \
|
||||
const char *msg = test(); \
|
||||
if (msg) { return msg; } \
|
||||
} while (0)
|
||||
|
||||
void test_init();
|
||||
uint32_t test_count_total();
|
||||
uint32_t test_count_success();
|
||||
uint32_t test_count_fail();
|
||||
|
||||
int test_buttons(void);
|
||||
|
||||
#endif // __TEST_H
|
||||
// Insert test methods here
|
||||
void test_buttons();
|
||||
void test_timespec();
|
||||
|
Reference in New Issue
Block a user