feat(cpp): unify macros for local testing

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2024-02-28 12:25:35 +01:00
parent 78e46a06ff
commit 51aa29e572
Signed by: mfocko
GPG key ID: 7C47D46246790496
2 changed files with 12 additions and 7 deletions

View file

@ -1,14 +1,14 @@
CXX=clang++
CXXFLAGS=-std=c++20 -Wall -Wextra
MACROS ?= -DTEST
MACROS ?= -D_MF_TEST
# COMMON_PATH=../.common/cpp
# $(COMMON_PATH)/catch2.o: $(COMMON_PATH)/catch_amalgamated.cpp $(COMMON_PATH)/catch_amalgamated.hpp
# $(CXX) $(CXXFLAGS) -g -c $(COMMON_PATH)/catch_amalgamated.cpp -o $(COMMON_PATH)/catch2.o
%: %.cpp
$(CXX) $(CXXFLAGS) $(MACROS) -DLOCAL -g $^ -o $@
$(CXX) $(CXXFLAGS) $(MACROS) -g $^ -o $@
format:
clang-format -i -style=google *.cpp

View file

@ -102,7 +102,7 @@ void dbg_out(Head H, Tail... T) {
std::cerr << ' ' << H;
dbg_out(T...);
}
#ifdef LOCAL
#ifdef _MF_TEST
#define dbg(...) \
std::cerr << '[' << __FILE__ << ':' << __LINE__ << "] (" << #__VA_ARGS__ \
<< "):", \
@ -265,12 +265,17 @@ std::ostream &operator<<(std::ostream &os, const C &v) {
template <typename T>
inline void answer(const T &ans) {
#ifdef _MF_TEST
std::cout << "Answer: ";
#endif
std::cout << ans << "\n";
}
inline void yes() { std::cout << "YES\n"; }
inline void no() { std::cout << "NO\n"; }
inline void yesno(bool ans) { std::cout << (ans ? "YES" : "NO") << "\n"; }
inline void yes() { answer("YES"); }
inline void no() { answer("NO"); }
inline void yesno(bool ans) { answer(ans ? "YES" : "NO"); }
#pragma endregion /* output */
#pragma region rng
@ -300,7 +305,7 @@ void tests() {
using namespace solution;
#ifdef TEST
#ifdef _MF_UNIT_TESTS
int main(void) {
tests();