Пример #1
0
// setFirst
TEST(StudentClass, STUDENT_CLASS_5) {
  const char *first = "";
  const char *ssn = "";

  const char *text_short = "1234567890";
  const char *text_long = "123456789012345678901234567890123456789012345678901234567890123";
  const char *text_long1 = "1234567890123456789012345678901234567890123456789012345678901234";
  const char *text_long2 = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";

  Student s;

  EXPECT_EQ(s.getAge(), 0);
  EXPECT_EQ(s.getLast(), (void *)0);
  EXPECT_EQ(s.getFirst(), (void *)0);
  EXPECT_EQ(s.getEmail(), (void *)0);
  EXPECT_EQ(std::strcmp(s.getSsn(), ssn), 0);

  s.setFirst(text_short);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_short), 0);
  s.setFirst(first);
  EXPECT_EQ(std::strcmp(s.getFirst(), first), 0);
  s.setFirst(text_long);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_long), 0);
  s.setFirst(0);
  EXPECT_EQ(s.getFirst(), (void *)0);
  s.setFirst(text_long1);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_long1), 0);
  s.setFirst(text_long2);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_long2), 0);
  s.setFirst(text_short);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_short), 0);
  s.setFirst(0);
  EXPECT_EQ(s.getFirst(), (void *)0);
}
Пример #2
0
// assignment operator
TEST(StudentClass, STUDENT_CLASS_14) {
  const int  age = 1;
  const char *last = "a";
  const char *first = "b";
  const char *email = "c";
  const char *ssn = "999-99-9999";
  const Student s(age, last, first, email, ssn);

  EXPECT_EQ(s.getAge(), age);
  EXPECT_EQ(std::strcmp(s.getLast(), last), 0);
  EXPECT_EQ(std::strcmp(s.getFirst(), first), 0);
  EXPECT_EQ(std::strcmp(s.getEmail(), email), 0);
  EXPECT_EQ(std::strcmp(s.getSsn(), ssn), 0);

  Student t;

  t = s;

  EXPECT_EQ(t.getAge(), age);
  EXPECT_EQ(std::strcmp(t.getLast(), last), 0);
  EXPECT_EQ(std::strcmp(t.getFirst(), first), 0);
  EXPECT_EQ(std::strcmp(t.getEmail(), email), 0);
  EXPECT_EQ(std::strcmp(t.getSsn(), ssn), 0);

  EXPECT_NE(t.getLast(), s.getLast());
  EXPECT_NE(t.getFirst(), s.getFirst());
  EXPECT_NE(t.getEmail(), s.getEmail());
  EXPECT_NE(t.getSsn(), s.getSsn());
}
Пример #3
0
// default constructor
TEST(StudentClass, STUDENT_CLASS_1) {
  const Student s;

  EXPECT_EQ(s.getAge(), 0);
  EXPECT_EQ(s.getLast(), (void *)0);
  EXPECT_EQ(s.getFirst(), (void *)0);
  EXPECT_EQ(s.getEmail(), (void *)0);
  EXPECT_EQ(std::strcmp(s.getSsn(), ""), 0);
}
Пример #4
0
bool Team::checkTeam() const {

    Student* student;
    int age;
    University* studentUniversity;

    int captainCount = 0;
    int studentCount = 0;
    float totalAge = 0;

    cout << "HELLO" << endl;

    for (int i=0; i<4; i++){
        student = students[i];

        if (student == 0){
            continue;
        }

        cout << student->getName() << endl;

        studentCount += 1;

        age = student->getAge();
        if ((age < 18) || (age > 40)){
            return false;
        }

        totalAge += (float) age;

        if (student->getCaptain()){
            captainCount++;
        }

        studentUniversity = &student->getUniversity();

        if (studentUniversity == 0){
            return false;
        }

        if (*studentUniversity != *university){
            return false;
        }

    }

    if (captainCount != 1) return false;
    if (studentCount != 4) return false;
    if (totalAge/4 > 24) return false;

    return true;

}
Пример #5
0
void AcademyGroup::AddStudents(Student & add){
	if (count % sizof == 0 && count != 0){
		Student **pStTemp = new  Student*[count + sizof]; if (!pStTemp) { exit(0); }
		int i;
		for (i = 0; i < count; i++){
			pStTemp[i] = pSt[i];
		}
		delete[] pSt;
		pSt = pStTemp;
		for (; i < count + sizof; i++){
			pSt[i] = new Student; if (!pSt[i]) { exit(0); }
		}
	}
	delete pSt[count];
	pSt[count] = new Student(add.getName(), add.getSurname(), add.getAge(), add.getPhone(), add.getAverage()); if (!pSt[count]) { exit(0); }
	count++;
}
Пример #6
0
// setSsn
TEST(StudentClass, STUDENT_CLASS_3) {
  const char *ssn = "";
  Student s;

  EXPECT_EQ(s.getAge(), 0);
  EXPECT_EQ(s.getLast(), (void *)0);
  EXPECT_EQ(s.getFirst(), (void *)0);
  EXPECT_EQ(s.getEmail(), (void *)0);
  EXPECT_EQ(std::strcmp(s.getSsn(), ssn), 0);

  s.setSsn("999-99-9999");
  EXPECT_EQ(std::strcmp(s.getSsn(), "999-99-9999"), 0);
  s.setSsn("999-99-999");
  EXPECT_EQ(std::strcmp(s.getSsn(), ""), 0);
  s.setSsn("111-11-1111");
  EXPECT_EQ(std::strcmp(s.getSsn(), "111-11-1111"), 0);
  s.setSsn("999-99-99999");
  EXPECT_EQ(std::strcmp(s.getSsn(), ""), 0);
}
Пример #7
0
// setLast, setFirst, setEmail
TEST(StudentClass, STUDENT_CLASS_7) {
  const char *ssn = "";
  const char *text_over2 = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";
  Student s;


  EXPECT_EQ(s.getAge(), 0);
  EXPECT_EQ(s.getLast(), (void *)0);
  EXPECT_EQ(s.getFirst(), (void *)0);
  EXPECT_EQ(s.getEmail(), (void *)0);
  EXPECT_EQ(std::strcmp(s.getSsn(), ssn), 0);

  s.setLast(text_over2);
  s.setFirst(text_over2);
  s.setEmail(text_over2);
  EXPECT_EQ(std::strcmp(s.getLast(), text_over2), 0);
  EXPECT_EQ(std::strcmp(s.getFirst(), text_over2), 0);
  EXPECT_EQ(std::strcmp(s.getEmail(), text_over2), 0);
}
Пример #8
0
// setAge
TEST(StudentClass, STUDENT_CLASS_2) {
  const char *ssn = "";
  Student s;

  EXPECT_EQ(s.getAge(), 0);
  EXPECT_EQ(s.getLast(), (void *)0);
  EXPECT_EQ(s.getFirst(), (void *)0);
  EXPECT_EQ(s.getEmail(), (void *)0);
  EXPECT_EQ(std::strcmp(s.getSsn(), ssn), 0);

  s.setAge(-10);
  EXPECT_EQ(s.getAge(), 0);
  s.setAge(1);
  EXPECT_EQ(s.getAge(), 1);
  s.setAge(0);
  EXPECT_EQ(s.getAge(), 0);
  s.setAge(150);
  EXPECT_EQ(s.getAge(), 150);
  s.setAge(151);
  EXPECT_EQ(s.getAge(), 0);
}