// Input Operator
TEST(StudentLinkedList, ISTREAM_1) {
    StudentLinkedList lst;
    Student s;
    std::stringstream ss,tt;
    
    ss << "123 Jones Davey [email protected] 999-99-9999" << std::endl;
    ss << "30 Builder Bob [email protected] 999-77-9999" << std::endl;
    ss << "40 Dug Dig [email protected] 999-33-9999" << std::endl;
    ss << "40 Dug Dig [email protected] 999-33-9999" << std::endl;
    ss << "30 Builder Bob [email protected] 999-77-9999" << std::endl;
    ss << "70 Doe Jane [email protected] 999-55-9999" << std::endl;
    
    ss >> lst;
    
    // check for existence
    ss.clear(); ss.seekg(0); // rewind to beginning
    while(ss >> s)
    {
        EXPECT_EQ(lst.Exists(s), true);
    }
    
    // check for duplicates
    ss.clear(); ss.seekg(0); // rewind to beginning
    int count = 0;
    while(ss >> s)
    {
        if(lst.Delete(s))
        {
            count ++;
        }
    }
    EXPECT_EQ(count, 4);
}
Beispiel #2
0
int main()
{ 
	char mLastName[15];
	char mFirstName[15];
	char mEmail[30];
	char mSsn[12];
	int mAge;

	std::ifstream myfile;
	myfile.open("testnames.txt");
	while(! myfile.eof())
	{

		myfile >> mLastName >> mFirstName >> mSsn >> mEmail >> mAge >> std::ws;
		Student nStudent(mLastName, mFirstName, mSsn, mEmail, mAge);
		Student mNStudent;
		StudentLinkedList sList;
		if(!sList.Exists(nStudent))
		{
			sList.AddStudent(nStudent);
			mNStudent = sList.RetrieveStudent(nStudent);
			std::cout << mNStudent.GetSsn() << std::endl;
		}
	}
	myfile.close();
  
return 0;
}
// Output Operator
TEST(StudentLinkedList, OSTREAM_2) {
    StudentLinkedList lst;
    Student s;
    std::stringstream ss,tt;
    
    ss << "123 Jones Davey [email protected] 999-99-9999" << std::endl;
    ss << "30 Builder Bob [email protected] 999-77-9999" << std::endl;
    ss << "40 Dug Dig [email protected] 999-33-9999" << std::endl;
    ss << "40 Dug Dig [email protected] 999-33-9999" << std::endl;
    ss << "30 Builder Bob [email protected] 999-77-9999" << std::endl;
    ss << "70 Doe Jane [email protected] 999-55-9999" << std::endl;
    
    while(ss >> s)
    {
        lst.Insert(s);
    }
    
    tt << lst;
    
    // test for last character
    std::string str = tt.str();
    EXPECT_EQ(str[str.size()-1], '9');
    int count = 0;
    while(tt >> s)
    {
        EXPECT_EQ(lst.Exists(s), true);
        count ++;
    }
    EXPECT_EQ(count, 4); // unique entries
}