add tests.hpp

This commit is contained in:
hugogogo
2022-06-03 12:47:53 +02:00
parent f130359980
commit 921d9b5e36
4 changed files with 69 additions and 31 deletions

View File

@@ -130,12 +130,17 @@ endfunction
function! COLORFile() function! COLORFile()
silent! 0r $HOME/.vim/templates/skeleton_colors.h silent! 0r $HOME/.vim/templates/skeleton_colors.h
endfunction endfunction
" to autofill a new tests.hpp file
function! TESTSFile()
silent! 0r $HOME/.vim/templates/skeleton_tests.hpp
endfunction
" autofill calls " autofill calls
autocmd BufNewFile *.hpp call HPPFile() autocmd BufNewFile *.hpp call HPPFile()
autocmd BufNewFile *.cpp if @% == 'main.cpp' | call MAINCPPFile() | else | call CPPFile() autocmd BufNewFile *.cpp if @% == 'main.cpp' | call MAINCPPFile() | else | call CPPFile()
autocmd BufNewFile Makefile call MAKEFile() autocmd BufNewFile Makefile call MAKEFile()
autocmd BufNewFile colors.h call COLORFile() autocmd BufNewFile colors.h call COLORFile()
autocmd BufNewFile testss.hpp call TESTSFile()

View File

@@ -1,8 +1,8 @@
# - - - - - - - # # - - - - - - #
# # # #
# COLORS # # COLORS #
# # # #
# - - - - - - - # # - - - - - - #
GRAY = "\e[0;30m" GRAY = "\e[0;30m"
RED = "\e[0;31m" RED = "\e[0;31m"
@@ -30,43 +30,43 @@ RESET = "\e[0m"
# . name is case sensitive . ?= set if not already set # # . name is case sensitive . ?= set if not already set #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
NAME = a.out NAME = a.out
#TYPE = c #CC = c
TYPE = cpp #EXT = c
CC = c++
EXT = cpp
ifeq "$(TYPE)" "c" CFLAGS = -Wall -Wextra -Werror $(INCLUDES)
CC = c #CFLAGS += -std=c++98
EXT = c CFLAGS += -g3
else ifeq "$(TYPE)" "cpp"
CC = c++
EXT = cpp
endif
CFLAGS = -Wall -Wextra -Werror $(INCLUDES) VPATH = $(D_SRCS)
ifeq "$(TYPE)" "cpp"
CFLAGS += -std=c++98
endif
VPATH = $(D_SRCS) LIBS =
LIBS = F_INCLUDES = $(HEADERS:%=$(D_HEADERS)/%) \
$(TEMPLATES:%=$(D_TEMPLATES)/%)
INCLUDES = -I$(D_HEADERS) \
-I$(D_TEMPLATES)
INCLUDES = -I$(D_HEADERS) D_SRCS = ./srcs
SRCS = main.c
D_SRCS = . D_HEADERS = ./headers
SRCS = main.cpp HEADERS = colors.h \
tests.hpp
D_HEADERS = . D_TEMPLATES = ./templates
HEADERS = colors.h TEMPLATES = template.tpp
D_OBJS = builds D_OBJS = builds
OBJS = $(SRCS:%.$(EXT)=$(D_OBJS)/%.o) OBJS = $(SRCS:%.$(EXT)=$(D_OBJS)/%.o)
ifeq "$(D_OBJS)" "." ifeq "$(D_OBJS)" "."
RM_OBJS = rm -f $(OBJS) RM_OBJS = rm -f $(OBJS)
else else
RM_OBJS = rm -rf $(D_OBJS) RM_OBJS = rm -rf $(D_OBJS)
endif endif
@@ -79,14 +79,16 @@ endif
all: $(NAME) all: $(NAME)
$(D_OBJS)/%.o: %.$(EXT) | $(D_OBJS) $(D_OBJS)/%.o: %.$(EXT) | $(D_OBJS)
@echo $(CYAN)"compilation (objects.o) :"$(RESET)
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
$(D_OBJS): $(D_OBJS):
mkdir $@ mkdir $@
$(OBJS): $(HEADERS:%=$(D_HEADERS)/%) $(OBJS): $(F_INCLUDES)
$(NAME): $(OBJS) $(NAME): $(OBJS)
@echo $(CYAN)"linkage (link objects.o) :"$(RESET)
$(CC) $(OBJS) -o $@ $(LIBS) $(CC) $(OBJS) -o $@ $(LIBS)
leaks: $(NAME) leaks: $(NAME)

View File

@@ -0,0 +1,30 @@
#ifndef TESTS_H
# define TESTS_H
#include <vector>
#include <string>
# define TEST(s) \
{\
test_title = #s;\
struct tester : public test_base {\
void func()
# define TESTEND \
};\
test = new(tester);\
test->title = test_title;\
test_list.push_back(test);\
}
struct test_base {
std::string title;
virtual void func() {}
};
std::vector<test_base *> test_list;
test_base *test;
std::string test_title;
#endif

View File

@@ -75,6 +75,7 @@ install "$HOME/.screenrc"
install "$HOME/.vimrc" install "$HOME/.vimrc"
install "$HOME/.zshrc" install "$HOME/.zshrc"
install "$HOME/.vim/templates/skeleton_colors.h" install "$HOME/.vim/templates/skeleton_colors.h"
install "$HOME/.vim/templates/skeleton_tests.hpp"
install "$HOME/.vim/templates/skeleton.cpp" install "$HOME/.vim/templates/skeleton.cpp"
install "$HOME/.vim/templates/skeleton.hpp" install "$HOME/.vim/templates/skeleton.hpp"
install "$HOME/.vim/templates/skeleton_main.cpp" install "$HOME/.vim/templates/skeleton_main.cpp"