From 9dd7a48967f99793b818f7362ac8e95717186774 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Tue, 10 Nov 2020 09:26:04 +0100 Subject: Added more tests for cpp01/07 --- cpp02/ex00/Fixed.cpp | 5 +++-- cpp02/ex00/Fixed.hpp | 6 +++--- cpp02/ex00/main.cpp | 27 --------------------------- cpp02/ex00/main_DO_NOT_TURN_ME_IN.cpp | 27 +++++++++++++++++++++++++++ cpp02/ex01/Fixed.cpp | 5 +++-- cpp02/ex01/Fixed.hpp | 4 ++-- 6 files changed, 38 insertions(+), 36 deletions(-) delete mode 100644 cpp02/ex00/main.cpp create mode 100644 cpp02/ex00/main_DO_NOT_TURN_ME_IN.cpp (limited to 'cpp02') diff --git a/cpp02/ex00/Fixed.cpp b/cpp02/ex00/Fixed.cpp index eb0501b..fc50102 100644 --- a/cpp02/ex00/Fixed.cpp +++ b/cpp02/ex00/Fixed.cpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 11:45:18 by charles #+# #+# */ -/* Updated: 2020/04/13 11:58:37 by charles ### ########.fr */ +/* Updated: 2020/11/09 13:07:28 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,10 +29,11 @@ Fixed::~Fixed() std::cout << "Destructor called" << std::endl; } -void Fixed::operator=(Fixed const& other) +Fixed& Fixed::operator=(Fixed const& other) { std::cout << "Assignation operator called" << std::endl; m_value = other.getRawBits(); + return *this; } int Fixed::getRawBits() const diff --git a/cpp02/ex00/Fixed.hpp b/cpp02/ex00/Fixed.hpp index 2ffe775..c8bdfb0 100644 --- a/cpp02/ex00/Fixed.hpp +++ b/cpp02/ex00/Fixed.hpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 11:40:49 by charles #+# #+# */ -/* Updated: 2020/10/19 08:27:01 by cacharle ### ########.fr */ +/* Updated: 2020/11/09 13:10:35 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,13 +21,13 @@ public: Fixed(); Fixed(Fixed const& other); ~Fixed(); - void operator=(Fixed const& other); + Fixed& operator=(Fixed const& other); int getRawBits() const; void setRawBits(int const raw); private: - int m_value; + int m_value; static int const m_fractional_bits = 8; }; diff --git a/cpp02/ex00/main.cpp b/cpp02/ex00/main.cpp deleted file mode 100644 index 494dbb3..0000000 --- a/cpp02/ex00/main.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* main.cpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: charles +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/04/13 11:51:15 by charles #+# #+# */ -/* Updated: 2020/04/13 11:51:16 by charles ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include -#include "Fixed.hpp" - -int main(void) -{ - Fixed a; - Fixed b(a); - Fixed c; - - c = b; - std::cout << a.getRawBits() << std::endl; - std::cout << b.getRawBits() << std::endl; - std::cout << c.getRawBits() << std::endl; - return 0; -} diff --git a/cpp02/ex00/main_DO_NOT_TURN_ME_IN.cpp b/cpp02/ex00/main_DO_NOT_TURN_ME_IN.cpp new file mode 100644 index 0000000..494dbb3 --- /dev/null +++ b/cpp02/ex00/main_DO_NOT_TURN_ME_IN.cpp @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 11:51:15 by charles #+# #+# */ +/* Updated: 2020/04/13 11:51:16 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "Fixed.hpp" + +int main(void) +{ + Fixed a; + Fixed b(a); + Fixed c; + + c = b; + std::cout << a.getRawBits() << std::endl; + std::cout << b.getRawBits() << std::endl; + std::cout << c.getRawBits() << std::endl; + return 0; +} diff --git a/cpp02/ex01/Fixed.cpp b/cpp02/ex01/Fixed.cpp index a81c1cf..14ba1c6 100644 --- a/cpp02/ex01/Fixed.cpp +++ b/cpp02/ex01/Fixed.cpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 11:45:18 by charles #+# #+# */ -/* Updated: 2020/11/08 13:38:40 by charles ### ########.fr */ +/* Updated: 2020/11/09 13:11:29 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,10 +28,11 @@ Fixed::~Fixed() std::cout << "Destructor called" << std::endl; } -void Fixed::operator=(Fixed const& other) +Fixed& Fixed::operator=(Fixed const& other) { std::cout << "Assignation operator called" << std::endl; m_value = other.getRawBits(); + return *this; } Fixed::Fixed(const int from) diff --git a/cpp02/ex01/Fixed.hpp b/cpp02/ex01/Fixed.hpp index a262c59..1f768f6 100644 --- a/cpp02/ex01/Fixed.hpp +++ b/cpp02/ex01/Fixed.hpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 11:40:49 by charles #+# #+# */ -/* Updated: 2020/11/08 13:38:48 by charles ### ########.fr */ +/* Updated: 2020/11/09 13:11:15 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,7 @@ public: Fixed(); Fixed(Fixed const& other); ~Fixed(); - void operator=(Fixed const& other); + Fixed& operator=(Fixed const& other); Fixed(const int from); Fixed(const float from); -- cgit