d07 ex00 ajout 1 test

This commit is contained in:
hugogogo
2022-03-10 17:52:05 +01:00
parent a8b1a6af1b
commit 3433fafd87
5 changed files with 68 additions and 14 deletions

View File

@@ -31,8 +31,9 @@ INCLUDES = -I$(D_HEADERS)
D_SRCS = . D_SRCS = .
SRCS = main.cpp SRCS = main.cpp
D_HEADERS = headers D_HEADERS = .
HEADERS = Templates.hpp HEADERS = colors.h \
Templates.hpp
D_OBJS = builds D_OBJS = builds
OBJS = $(SRCS:%.$(EXT)=$(D_OBJS)/%.o) OBJS = $(SRCS:%.$(EXT)=$(D_OBJS)/%.o)

25
d07/ex00/colors.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef COLORS_H
# define COLORS_H
# define GRAY "\e[0;30m"
# define RED "\e[0;31m"
# define GREEN "\e[0;32m"
# define YELLOW "\e[0;33m"
# define BLUE "\e[0;34m"
# define PURPLE "\e[0;35m"
# define CYAN "\e[0;36m"
# define WHITE "\e[0;37m"
# define B_GRAY "\e[1;30m"
# define B_RED "\e[1;31m"
# define B_GREEN "\e[1;32m"
# define B_YELLOW "\e[1;33m"
# define B_BLUE "\e[1;34m"
# define B_PURPLE "\e[1;35m"
# define B_CYAN "\e[1;36m"
# define B_WHITE "\e[1;37m"
# define RESET "\e[0m"
#endif

View File

@@ -1,23 +1,51 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "colors.h"
#include "Templates.hpp" #include "Templates.hpp"
#define N_TEST "3"
int main() { int main() {
int a = 2; int i = 0;
int b = 3;
::swap( a, b ); std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
std::cout << "a = " << a << ", b = " << b << std::endl; << "tests int :" RESET "\n";
std::cout << "min( a, b ) = " << ::min( a, b ) << std::endl; {
std::cout << "max( a, b ) = " << ::max( a, b ) << std::endl; int a = 2;
int b = 3;
std::cout << "a = " << a << ", b = " << b << "\nswap :\n";
::swap( a, b );
std::cout << "a = " << a << ", b = " << b << "\n";
std::cout << "min( a, b ) = " << ::min( a, b ) << "\n";
std::cout << "max( a, b ) = " << ::max( a, b ) << "\n";
}
std::string c = "chaine1"; std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
std::string d = "chaine2"; << "tests string :" RESET "\n";
{
std::string a = "chaine1";
std::string b = "chaine2";
std::cout << "a = " << a << ", b = " << b << "\nswap :\n";
::swap(a, b);
std::cout << "a = " << a << ", b = " << b << "\n";
std::cout << "min( a, b ) = " << ::min( a, b ) << "\n";
std::cout << "max( a, b ) = " << ::max( a, b ) << "\n";
}
::swap(c, d); std::cout << B_YELLOW "\n[" << ++i << "/" N_TEST "] "
std::cout << "c = " << c << ", d = " << d << std::endl; << "tests floats :" RESET "\n";
std::cout << "min( c, d ) = " << ::min( c, d ) << std::endl; {
std::cout << "max( c, d ) = " << ::max( c, d ) << std::endl; float a = 2.42f;
float b = 32.7f;
std::cout << "a = " << a << ", b = " << b << "\nswap :\n";
::swap( a, b );
std::cout << "a = " << a << ", b = " << b << "\n";
std::cout << "min( a, b ) = " << ::min( a, b ) << "\n";
std::cout << "max( a, b ) = " << ::max( a, b ) << "\n";
}
return 0; return 0;
} }

Binary file not shown.