increment age
This commit is contained in:
parent
b05277eeee
commit
2839ef51cc
|
|
@ -1,11 +1,25 @@
|
||||||
#include "Person.h"
|
#include "Person.h"
|
||||||
|
|
||||||
|
Person::Person() : myName("Willy"), myAge(32)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
std::string Person::getName() const
|
std::string Person::getName() const
|
||||||
{
|
{
|
||||||
return "Willy";
|
return "myName";
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Person::getAge() const
|
unsigned int Person::getAge() const
|
||||||
{
|
{
|
||||||
return 32;
|
return myAge;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Person::setName(const std::string& name)
|
||||||
|
{
|
||||||
|
myName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Person::setAge(unsigned int age)
|
||||||
|
{
|
||||||
|
myAge = age;
|
||||||
}
|
}
|
||||||
|
|
@ -7,4 +7,11 @@ class Person
|
||||||
public:
|
public:
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
unsigned int getAge() const;
|
unsigned int getAge() const;
|
||||||
|
|
||||||
|
void setName(const std::string& name);
|
||||||
|
void setAge(unsigned int age);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string myName;
|
||||||
|
unsigned int myAge;
|
||||||
};
|
};
|
||||||
|
|
@ -9,5 +9,11 @@ int main()
|
||||||
|
|
||||||
Person p;
|
Person p;
|
||||||
cout << "Hello " << p.getName() << " : " << p.getAge() << " yo !" << endl;
|
cout << "Hello " << p.getName() << " : " << p.getAge() << " yo !" << endl;
|
||||||
|
|
||||||
|
p.setName("Willy BECHIER");
|
||||||
|
p.setAge(p.getAge() + 1);
|
||||||
|
|
||||||
|
cout << "Hello " << p.getName() << " : " << p.getAge() << " yo !" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,40 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "Person.h"
|
#include "Person.h"
|
||||||
|
|
||||||
TEST(PersonTest, VerifyName)
|
TEST(PersonTest, DefaultValues)
|
||||||
{
|
{
|
||||||
Person person;
|
Person person;
|
||||||
|
|
||||||
EXPECT_EQ(person.getName(), "Willy");
|
EXPECT_EQ(person.getName(), "Willy");
|
||||||
|
EXPECT_EQ(person.getAge(), 32u);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PersonTest, VerifyAge)
|
TEST(PersonTest, ModifiedValues)
|
||||||
{
|
{
|
||||||
Person person;
|
Person person;
|
||||||
|
|
||||||
|
person.setName("Willy BECHIER");
|
||||||
|
person.setAge(person.getAge() + 1);
|
||||||
|
|
||||||
|
EXPECT_EQ(person.getName(), "Willy BECHIER");
|
||||||
|
EXPECT_EQ(person.getAge(), 33u);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PersonTest, DefaultValues)
|
||||||
|
{
|
||||||
|
Person person;
|
||||||
|
|
||||||
|
EXPECT_EQ(person.getName(), "Willy");
|
||||||
EXPECT_EQ(person.getAge(), 32u);
|
EXPECT_EQ(person.getAge(), 32u);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PersonTest, ModifiedValuesFAILED)
|
||||||
|
{
|
||||||
|
Person person;
|
||||||
|
|
||||||
|
person.setName("Willy BECHIER");
|
||||||
|
person.setAge(person.getAge() + 1);
|
||||||
|
|
||||||
|
EXPECT_EQ(person.getName(), "Wily BECHIER");
|
||||||
|
EXPECT_EQ(person.getAge(), 34u);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue