feat(data): SPSC ring buffer, incremental min/max LOD pyramid, series types
This commit is contained in:
1 parent
c93c98002b
commit
138fa478c3
15 files changed
+1182
-8
No files matched your search
+19
-8
@@ -35,6 +35,23 @@ struct Failure {
|
||||
std::string msg;
|
||||
};
|
||||
|
||||
/// Compares two doubles within `eps`. `PLOT_CHECK_NEAR(a, b)` leaves it to the
|
||||
/// default below; pass an explicit tolerance for computed values.
|
||||
inline constexpr double kNearEps = 1e-9;
|
||||
|
||||
inline void check_near(double a, double b, double eps, const char* file, int line,
|
||||
const char* lhs, const char* rhs) {
|
||||
if (!(std::fabs(a - b) <= eps)) {
|
||||
throw Failure{std::string(file) + ":" + std::to_string(line) + " CHECK_NEAR(" + lhs + ", " +
|
||||
rhs + ") got " + std::to_string(a) + " vs " + std::to_string(b)};
|
||||
}
|
||||
}
|
||||
|
||||
inline void check_near(double a, double b, const char* file, int line, const char* lhs,
|
||||
const char* rhs) {
|
||||
check_near(a, b, kNearEps, file, line, lhs, rhs);
|
||||
}
|
||||
|
||||
inline int run_all() {
|
||||
int failed = 0;
|
||||
for (auto& c : cases()) {
|
||||
@@ -64,11 +81,5 @@ inline int run_all() {
|
||||
" CHECK(" #cond ")"}; \
|
||||
} while (0)
|
||||
|
||||
#define PLOT_CHECK_NEAR(a, b, eps) \
|
||||
do { \
|
||||
const double _a = (a), _b = (b); \
|
||||
if (!(std::fabs(_a - _b) <= (eps))) \
|
||||
throw ::plottest::Failure{std::string(__FILE__) + ":" + std::to_string(__LINE__) + \
|
||||
" CHECK_NEAR(" #a ", " #b ") got " + std::to_string(_a) + \
|
||||
" vs " + std::to_string(_b)}; \
|
||||
} while (0)
|
||||
#define PLOT_CHECK_NEAR(a, b, ...) \
|
||||
::plottest::check_near((a), (b) __VA_OPT__(,) __VA_ARGS__, __FILE__, __LINE__, #a, #b)
|
||||
Reference in new issue
Block a user