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

View File

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