mirror of
https://gitlab.com/mfocko/Codeforces.git
synced 2024-12-22 01:21:21 +01:00
feat(cpp): unify macros for local testing
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
78e46a06ff
commit
51aa29e572
2 changed files with 12 additions and 7 deletions
|
@ -1,14 +1,14 @@
|
||||||
CXX=clang++
|
CXX=clang++
|
||||||
CXXFLAGS=-std=c++20 -Wall -Wextra
|
CXXFLAGS=-std=c++20 -Wall -Wextra
|
||||||
|
|
||||||
MACROS ?= -DTEST
|
MACROS ?= -D_MF_TEST
|
||||||
|
|
||||||
# COMMON_PATH=../.common/cpp
|
# COMMON_PATH=../.common/cpp
|
||||||
# $(COMMON_PATH)/catch2.o: $(COMMON_PATH)/catch_amalgamated.cpp $(COMMON_PATH)/catch_amalgamated.hpp
|
# $(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
|
# $(CXX) $(CXXFLAGS) -g -c $(COMMON_PATH)/catch_amalgamated.cpp -o $(COMMON_PATH)/catch2.o
|
||||||
|
|
||||||
%: %.cpp
|
%: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) $(MACROS) -DLOCAL -g $^ -o $@
|
$(CXX) $(CXXFLAGS) $(MACROS) -g $^ -o $@
|
||||||
|
|
||||||
format:
|
format:
|
||||||
clang-format -i -style=google *.cpp
|
clang-format -i -style=google *.cpp
|
||||||
|
|
|
@ -102,7 +102,7 @@ void dbg_out(Head H, Tail... T) {
|
||||||
std::cerr << ' ' << H;
|
std::cerr << ' ' << H;
|
||||||
dbg_out(T...);
|
dbg_out(T...);
|
||||||
}
|
}
|
||||||
#ifdef LOCAL
|
#ifdef _MF_TEST
|
||||||
#define dbg(...) \
|
#define dbg(...) \
|
||||||
std::cerr << '[' << __FILE__ << ':' << __LINE__ << "] (" << #__VA_ARGS__ \
|
std::cerr << '[' << __FILE__ << ':' << __LINE__ << "] (" << #__VA_ARGS__ \
|
||||||
<< "):", \
|
<< "):", \
|
||||||
|
@ -265,12 +265,17 @@ std::ostream &operator<<(std::ostream &os, const C &v) {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void answer(const T &ans) {
|
inline void answer(const T &ans) {
|
||||||
|
|
||||||
|
#ifdef _MF_TEST
|
||||||
|
std::cout << "Answer: ";
|
||||||
|
#endif
|
||||||
|
|
||||||
std::cout << ans << "\n";
|
std::cout << ans << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void yes() { std::cout << "YES\n"; }
|
inline void yes() { answer("YES"); }
|
||||||
inline void no() { std::cout << "NO\n"; }
|
inline void no() { answer("NO"); }
|
||||||
inline void yesno(bool ans) { std::cout << (ans ? "YES" : "NO") << "\n"; }
|
inline void yesno(bool ans) { answer(ans ? "YES" : "NO"); }
|
||||||
#pragma endregion /* output */
|
#pragma endregion /* output */
|
||||||
|
|
||||||
#pragma region rng
|
#pragma region rng
|
||||||
|
@ -300,7 +305,7 @@ void tests() {
|
||||||
|
|
||||||
using namespace solution;
|
using namespace solution;
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef _MF_UNIT_TESTS
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
tests();
|
tests();
|
||||||
|
|
Loading…
Reference in a new issue