feat: adding test

This commit is contained in:
Raphael 2025-03-24 15:17:03 +01:00
parent 844e094c1a
commit d32b496a87
4 changed files with 109 additions and 72 deletions

View file

@ -6,7 +6,7 @@
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
# Updated: 2025/03/23 18:59:18 by rparodi ### ########.fr #
# Updated: 2025/03/24 14:51:15 by rparodi ### ########.fr #
# #
# **************************************************************************** #
@ -116,7 +116,7 @@ footer:
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
clangd:
@echo \
@echo -e \
"CompileFlags:\n" \
" Add:\n" \
" - \"-std=c++98 -Wall -Wextra -Werror\"\n" \

View file

@ -6,18 +6,36 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/20 15:50:13 by rparodi #+# #+# */
/* Updated: 2025/03/22 22:20:50 by rparodi ### ########.fr */
/* Updated: 2025/03/24 14:44:46 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <iostream>
#include "color.hpp"
#include <cctype>
#include <cerrno>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
bool isInt(std::string const &str);
void convertInt(std::string const &str);
bool isChar(std::string const &str);
bool isDouble(std::string const &str);
bool isFloat(std::string const &str);
bool isInt(std::string const &str);
void convertChar(std::string const &str);
void convertDouble(std::string const &str);
void convertFloat(std::string const &str);
void convertInt(std::string const &str);
void minus_infinity();
void not_a_number();
void plus_infinity();
class ScalarConverter {
public:

View file

@ -6,42 +6,42 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/17 15:27:54 by rparodi #+# #+# */
/* Updated: 2024/12/23 12:36:02 by rparodi ### ########.fr */
/* Updated: 2025/03/24 13:58:15 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef COLOR_HPP
#define COLOR_HPP
#define CLR_RESET "\033[0m"
#define CLR_BLACK "\033[0;30m"
#define CLR_RED "\033[0;31m"
#define CLR_GREEN "\033[0;32m"
#define CLR_YELLOW "\033[0;33m"
#define CLR_BLUE "\033[0;34m"
#define CLR_MAGENTA "\033[0;35m"
#define CLR_CYAN "\033[0;36m"
#define CLR_WHITE "\033[0;37m"
#define CLR_GOLD "\033[38;5;220m"
#define CLR_GREY "\033[38;5;240m"
#define CLR_LIGHT_BLACK "\033[0;90m"
#define CLR_LIGHT_RED "\033[0;91m"
#define CLR_LIGHT_GREEN "\033[0;92m"
#define CLR_LIGHT_YELLOW "\033[0;93m"
#define CLR_LIGHT_BLUE "\033[0;94m"
#define CLR_LIGHT_MAGENTA "\033[0;95m"
#define CLR_LIGHT_CYAN "\033[0;96m"
#define CLR_LIGHT_WHITE "\033[0;97m"
#define CLR_BOLD_BLACK "\033[1;30m"
#define CLR_BOLD_RED "\033[1;31m"
#define CLR_BOLD_GREEN "\033[1;32m"
#define CLR_BOLD_YELLOW "\033[1;33m"
#define CLR_BOLD_BLUE "\033[1;34m"
#define CLR_BOLD_MAGENTA "\033[1;35m"
#define CLR_BOLD_CYAN "\033[1;36m"
#define CLR_BOLD_WHITE "\033[1;37m"
#define COLOR_HPP
#define CLR_RESET "\033[0m"
#define CLR_BLACK "\033[0;30m"
#define CLR_RED "\033[0;31m"
#define CLR_GREEN "\033[0;32m"
#define CLR_YELLOW "\033[0;33m"
#define CLR_BLUE "\033[0;34m"
#define CLR_MAGENTA "\033[0;35m"
#define CLR_CYAN "\033[0;36m"
#define CLR_WHITE "\033[0;37m"
#define CLR_GOLD "\033[38;5;220m"
#define CLR_GREY "\033[38;5;240m"
#define CLR_LIGHT_BLACK "\033[0;90m"
#define CLR_LIGHT_RED "\033[0;91m"
#define CLR_LIGHT_GREEN "\033[0;92m"
#define CLR_LIGHT_YELLOW "\033[0;93m"
#define CLR_LIGHT_BLUE "\033[0;94m"
#define CLR_LIGHT_MAGENTA "\033[0;95m"
#define CLR_LIGHT_CYAN "\033[0;96m"
#define CLR_LIGHT_WHITE "\033[0;97m"
#define CLR_BOLD_BLACK "\033[1;30m"
#define CLR_BOLD_RED "\033[1;31m"
#define CLR_BOLD_GREEN "\033[1;32m"
#define CLR_BOLD_YELLOW "\033[1;33m"
#define CLR_BOLD_BLUE "\033[1;34m"
#define CLR_BOLD_MAGENTA "\033[1;35m"
#define CLR_BOLD_CYAN "\033[1;36m"
#define CLR_BOLD_WHITE "\033[1;37m"
#endif

View file

@ -6,44 +6,63 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/20 15:49:02 by rparodi #+# #+# */
/* Updated: 2025/03/23 18:57:30 by rparodi ### ########.fr */
/* Updated: 2025/03/24 14:58:07 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ScalarConverter.hpp"
#include "color.hpp"
int main(void) {
int main(int argc, char *argv[]) {
ScalarConverter test;
std::string to_test;
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for 'a' ]" << CLR_RESET << std::endl;
to_test = "a";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for 0 ]" << CLR_RESET << std::endl;
to_test = "0";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for 4294967300 ]" << CLR_RESET << std::endl;
to_test = "4294967300";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for 42.42 ]" << CLR_RESET << std::endl;
to_test = "42.42";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for -inff ]" << CLR_RESET << std::endl;
to_test = "-inff";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for +inff ]" << CLR_RESET << std::endl;
to_test = "+inff";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for nanf ]" << CLR_RESET << std::endl;
to_test = "nanf";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for -inf ]" << CLR_RESET << std::endl;
to_test = "-inf";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for +inf ]" << CLR_RESET << std::endl;
to_test = "+inf";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for nan ]" << CLR_RESET << std::endl;
to_test = "nan";
test.convert(&to_test);
if (argc == 1) {
std::string to_test;
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for \"Hello World\" ]" << CLR_RESET << std::endl;
to_test = "Hello World";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for 'a' ]" << CLR_RESET << std::endl;
to_test = "a";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for 0 ]" << CLR_RESET << std::endl;
to_test = "0";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for -2147483648 ]" << CLR_RESET << std::endl;
to_test = "-2147483648";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for 2147483647 ]" << CLR_RESET << std::endl;
to_test = "2147483647";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for 4294967300 ]" << CLR_RESET << std::endl;
to_test = "4294967300";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for 42.42 ]" << CLR_RESET << std::endl;
to_test = "42.42";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for -42.42 ]" << CLR_RESET << std::endl;
to_test = "-42.42";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for -inff ]" << CLR_RESET << std::endl;
to_test = "-inff";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for +inff ]" << CLR_RESET << std::endl;
to_test = "+inff";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for nanf ]" << CLR_RESET << std::endl;
to_test = "nanf";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for -inf ]" << CLR_RESET << std::endl;
to_test = "-inf";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for +inf ]" << CLR_RESET << std::endl;
to_test = "+inf";
test.convert(&to_test);
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for nan ]" << CLR_RESET << std::endl;
to_test = "nan";
test.convert(&to_test);
} else {
std::cout << std::endl << CLR_YELLOW << "\t\t[ Testing all convertion for " << argv[1] << " ]" << CLR_RESET << std::endl;
std::string personnal_test = argv[1];
test.convert(&personnal_test);
}
std::cout << std::endl;
}