chore(cpp): don't use Catch2 to allow faster iterations

* Also rework the way ‹main› is done

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2023-07-29 15:59:06 +02:00
parent 17e43f0ebf
commit f6e3929fee
Signed by: mfocko
GPG key ID: 7C47D46246790496
2 changed files with 22 additions and 21 deletions

View file

@ -1,13 +1,14 @@
CXX=clang++
CXXFLAGS=-std=c++20 -Wall -Wextra
COMMON_PATH=../.common/cpp
MACROS ?= -DTEST
$(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
# 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
%: $(COMMON_PATH)/catch2.o %.cpp
$(CXX) $(CXXFLAGS) -DTEST -g $^ -o $@
%: %.cpp
$(CXX) $(CXXFLAGS) $(MACROS) -DLOCAL -g $^ -o $@
format:
clang-format -i -style=google *.cpp

View file

@ -78,6 +78,12 @@ using namespace std;
void solve() {
// TODO
dbg("Hello from debug");
answer("Hello");
}
void tests() {
// TODO
}
} // namespace solution
@ -86,32 +92,26 @@ using namespace solution;
#ifdef TEST
#include "../.common/cpp/catch_amalgamated.hpp"
TEST_CASE("examples") {
// TODO
int main(void) {
tests();
return 0;
}
#else
int main(void) {
int N = 1;
#ifdef SINGLE
#ifndef SINGLE
solution::solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solution::solve();
}
std::cin >> N;
#endif
while (N-- > 0) {
solve();
}
return 0;
}