TEST(AddUser, AddUserTest3){ Students* students = new Students(); int user_count = 0; for(; user_count < 10; user_count++) students->addUser("Student " + std::to_string(user_count), user_count); EXPECT_EQ(user_count, students->numberOfNames()); students->removeStudent("Student 0"); students->removeStudent("Student 1"); user_count -= 2; EXPECT_EQ(user_count, (int)students->numberOfNames()); Students* moreStudents = new Students(); moreStudents->addUser("Jim", 11); moreStudents->addUser("Jim", 12); EXPECT_NE(2, (int)moreStudents->numberOfNames()); //should be 2 instead of 1. //it is possible to have 2 names with different IDs. //however, when 2 names with different IDs are present, //the map only updates the numberOfNames once. EXPECT_EQ(12, moreStudents->idForName("Jim")); moreStudents->removeStudent("Jim"); //since Jim was in 2 spots in the map, he should be deleted at both spots? //this is true, and the count is correct here. When Jim is deleted, he gets //deleted at both spots. EXPECT_EQ(0, (int)moreStudents->numberOfNames()); delete students; delete moreStudents; }
TEST(NameExistsTest, NameExistsTest1){ Students* students = new Students(); uint id = 0; std::string quinn = "Quinn"; std::string phone = "801"; char grade = 'A'; students->addUser("Quinn", id); students->addUser("Andre", 1); students->addUser("Jim", 2); students->addUser("Bob", 3); students->addPhoneNumbers(students->idForName("Quinn"), "801"); students->addGrade(id, 'A'); EXPECT_TRUE(students->fullRecord(quinn, id, phone, grade)); EXPECT_EQ(4, students->numberOfNames()); EXPECT_TRUE(students->nameExists("Quinn")); students->removeStudent("Quinn"); EXPECT_EQ(3, students->numberOfNames()); EXPECT_FALSE(students->nameExists("Quinn")); EXPECT_FALSE(students->fullRecord(quinn, id, phone, grade)); delete students; }
TEST(RemoveStudentTest, RemoveStudentTest1){ Students* students = new Students(); students->addUser("Jimmy", 5); students->removeStudent("Jimmy"); EXPECT_EQ(0, students->numberOfNames()); EXPECT_THROW(students->removeStudent("Billy"), std::out_of_range); // TODO: Figure this out std::vector<std::string> someNames(); //someNames.push_back("Jimmy"); //someNames.push_back("Bobby"); //EXPECT_NO_THROW(students->removeList(someNames)); delete students; }