#include "catch.hpp" #include "Person.h" #include #include TEST_CASE ( "Constructor and to_string" ) { Person p{}; REQUIRE( p.to_string() == "" ); Person r{"Rasmus"}; REQUIRE( r.to_string() == "Rasmus" ); Person const c{"Constantine"}; REQUIRE( c.to_string() == "Constantine" ); } TEST_CASE ( "Binary + operator" ) { Person r{"Rasmus"}; Person rx{ r + "Pontus" }; REQUIRE( rx.to_string() == "RasmusPontus" ); Person const c{"Constantine"}; Person cr{ c + "Rasmus" }; REQUIRE( cr.to_string() == "ConstantineRasmus" ); } TEST_CASE ( "Unary prefix ++ operator" ) { Person x{"A"}; ++x; REQUIRE( x.to_string() == "AA" ); ++(++x); REQUIRE( x.to_string() == "AAAAAAAA" ); } TEST_CASE ( "Unary postfix ++ operator" ) { Person x{"A"}; x++; REQUIRE( x.to_string() == "AA" ); REQUIRE( x++.to_string() == "AA" ); REQUIRE( x.to_string() == "AAAA" ); } TEST_CASE ( "Binary << ostream operator" ) { Person p{"Pontus"}; std::stringstream strstream{}; strstream << p << p; REQUIRE( strstream.str() == "PontusPontus" ); }