Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extended ZEN_EXPECT while logging x value #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions zen/datas/alpha.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#pragma once

#include <queue>
#include<string>

namespace zen {

Expand Down Expand Up @@ -151,16 +152,30 @@ bool REPORT_TC_FAIL = true; // by default, do report fails (should be few)
// Example: ZEN_EXPECT(str == "good");
// Result: CASE PASS: ...
// or: CASE FAIL: ...

#define EQ(expected, actual) ((expected) == (actual))
#define IS_TRUE(expression) ((expression))
#define IS_FALSE(expression) (!(expression))
#define GT(value, other) ((value) > (other))
#define LT(value, other) ((value) < (other))
#define GE(value, other) ((value) >= (other))
#define LE(value, other) ((value) <= (other))
#define AND(condition1, condition2) ((condition1) && (condition2))
#define OR(condition1, condition2) ((condition1) || (condition2))
#define EXPECT_FLOAT_EQ(expected, actual, epsilon) (fabs((expected) - (actual)) < (epsilon))
#define EXPECT_DOUBLE_EQ(expected, actual, epsilon) (fabs((expected) - (actual)) < (epsilon))

#define ZEN_EXPECT(expression) \
do { \
if (expression) { \
bool result = (expression); \
if (result) { \
if (zen::REPORT_TC_PASS) \
zen::log(zen::color::green("CASE PASS:"), #expression); \
++zen::TEST_CASE_PASS_COUNT; \
} \
if (!(expression)) { \
if (zen::REPORT_TC_FAIL) \
} else { \
if (zen::REPORT_TC_FAIL) { \
zen::log(zen::color::red("CASE FAIL:"), __func__, "EXPECTED:", #expression); \
} \
++zen::TEST_CASE_FAIL_COUNT; \
} \
} while (0)
Expand Down Expand Up @@ -318,4 +333,4 @@ search_downward(std::string_view name, std::filesystem::path from = std::filesys
return std::nullopt;
}

} // namespace zen
} // namespace zen
Loading