-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_add_delete_fetch_combination.cpp
31 lines (25 loc) · 1.16 KB
/
test_add_delete_fetch_combination.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <fstream>
#include "interface_template.cpp"
int main() {
PhoneBook phone_book;
phone_book.readRecordsFromFile("Details_new.txt");
PhoneRecord new_contact("Venkata Subramanian", "Microsoft", {"8056297058"});
phone_book.addContact(&new_contact);
std::ofstream resultFile("test_results.txt", std::ios::app);
if (phone_book.deleteContact(new std::string("Venkata Subramanian"))) {
std::vector<PhoneRecord*> contacts_after_delete = phone_book.fetchContacts(new std::string("Venkata Subramanian"));
if (contacts_after_delete.empty()) {
std::cout << "test_add_delete_fetch_combination: Passed" << std::endl;
resultFile << "passed, test_add_delete_fetch_combination" << std::endl;
} else {
std::cerr << "test_add_delete_fetch_combination: Failed" << std::endl;
resultFile << "failed, test_add_delete_fetch_combination" << std::endl;
}
} else {
std::cerr << "test_add_delete_fetch_combination: Failed" << std::endl;
resultFile << "failed, test_add_delete_fetch_combination" << std::endl;
}
resultFile.close();
return 0;
}