42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#include "UserTable.h"
|
|
#include "User.h"
|
|
#include <cassert>
|
|
|
|
int main() {
|
|
{ /* User Related Tests */
|
|
// Two identical users
|
|
User u1 = User(1234, "Name Nameson");
|
|
User u2 = User(1234, "Name Nameson");
|
|
|
|
assert(u1.getName() == u2.getName());
|
|
assert(u1.getCardNbr() == u2.getCardNbr());
|
|
|
|
// Two different users
|
|
User u3 = User(1200, "Name Surname");
|
|
User u4 = User(1201, "Name Nameson");
|
|
|
|
assert(u3.getName() != u4.getName());
|
|
assert(u3.getCardNbr() != u4.getCardNbr());
|
|
}
|
|
{ /* Table Related Tests */
|
|
UserTable tbl1 = UserTable();
|
|
assert(tbl1.find("Jens Holmgren") == UserTable::user_not_found);
|
|
tbl1.addUser(User(1200, "Table Yes"));
|
|
assert(tbl1.getNbrUsers() == 1);
|
|
}
|
|
{
|
|
// Assumes 'users.txt' is present, containing
|
|
// line separated records formatted as:
|
|
// "89524 Adam Abrahamsson"
|
|
UserTable tbl = UserTable("users.txt");
|
|
assert(tbl.getNbrUsers() > 0);
|
|
assert(tbl.find("Jens Holmgren") != UserTable::user_not_found);
|
|
|
|
tbl.addUser(User(1200, "Name Surname"));
|
|
User ufind1 = tbl.find(1200);
|
|
assert(ufind1 != UserTable::user_not_found);
|
|
|
|
User ufind2 = tbl.find("Name Surname");
|
|
assert(ufind2 != UserTable::user_not_found);
|
|
}
|
|
}
|