d06 change test output

This commit is contained in:
Hugo LAMY
2022-03-17 14:27:32 +01:00
parent 4327b90c02
commit a7386b882e
4 changed files with 19 additions and 2 deletions

BIN
d06/ex00/convert Executable file

Binary file not shown.

View File

@@ -15,6 +15,8 @@ int main(int ac, char **av) {
return 0;
}
std::cout << "\n\n" B_GREEN "----------------------------------------------------\n"
<< "\nCHAR" RESET "\n";
// char
convert("!");
convert("\"");
@@ -100,6 +102,9 @@ int main(int ac, char **av) {
convert("|");
convert("}");
convert("~");
std::cout << "\n\n" B_GREEN "----------------------------------------------------\n"
<< "\nINT" RESET "\n";
// int
convert("0");
convert("-42");
@@ -147,6 +152,9 @@ int main(int ac, char **av) {
convert(MAX_FLOAT_INT_PREC_4);
convert(MAX_FLOAT_INT_PREC_5);
convert(MAX_FLOAT_INT_PREC_6);
std::cout << "\n\n" B_GREEN "----------------------------------------------------\n"
<< "\nFLOAT" RESET "\n";
// float
convert("0.0f");
convert("-4.2f");
@@ -181,6 +189,9 @@ int main(int ac, char **av) {
convert(MAX_F_5".0f");
convert(MAX_F_6".0f");
convert(MAX_F_N".0f");
std::cout << "\n\n" B_GREEN "----------------------------------------------------\n"
<< "\nDOUBLE" RESET "\n";
//double
convert("0.0");
convert("-4.2");

View File

@@ -22,10 +22,10 @@ bool isChar(std::string str) {
bool checkChar(std::string str) {
char c;
if (str.length() != 1 || isdigit(str[0]))
if (!isChar(str))
return false;
c = str[0];
c = str[0];
std::cout << B_CYAN << c << B_YELLOW " char" RESET "\n";
fromChar(c);

View File

@@ -2,6 +2,12 @@
#include <string>
#include "convert.h"
// f[] : is an array
// *f[] : is an array of pointers
// (*f[])() : is an array of pointers to functions with no parameters
// (*f[])(str) : is an array of pointers to functions with parameter str
// see :
// https://stackoverflow.com/questions/31643245/declaring-an-array-of-functions-of-type-void-c
bool (*checkFunc[])(std::string str) =
{
checkChar,