Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <cstdio>
|
|
|
|
class TestRunner {
|
|
public:
|
|
void run(const char* name, bool (*test)()) {
|
|
if (test()) {
|
|
std::printf("PASS %s\n", name);
|
|
return;
|
|
}
|
|
|
|
++failures_;
|
|
std::printf("FAIL %s\n", name);
|
|
}
|
|
|
|
int result() const {
|
|
return failures_ == 0 ? 0 : 1;
|
|
}
|
|
|
|
private:
|
|
int failures_ = 0;
|
|
};
|
|
|
|
#define CHECK(condition) \
|
|
do { \
|
|
if (!(condition)) { \
|
|
std::fprintf(stderr, " %s:%d: %s\n", __FILE__, __LINE__, #condition); \
|
|
return false; \
|
|
} \
|
|
} while (false)
|
|
|
|
void run_legacy_descriptor_tests(TestRunner& runner);
|
|
void run_switch2_command_tests(TestRunner& runner);
|
|
void run_switch2_descriptor_tests(TestRunner& runner);
|
|
void run_switch2_report_tests(TestRunner& runner);
|
|
void run_switch_input_tests(TestRunner& runner);
|
|
void run_switch_uart_protocol_tests(TestRunner& runner);
|