fork download
  1. /*
  2.  * nstest.cc: a program to test the three name server implementations.
  3.  */
  4. #include "nameserverinterface.h"
  5. #include "vectornameserver.h"
  6. // #include "mapnameserver.h"
  7. // #include "hashnameserver.h"
  8. #include <iostream>
  9. #include <cassert>
  10.  
  11. using namespace std;
  12. using namespace cpp_lab4;
  13.  
  14. void test(NameServerInterface& ns) {
  15. ns.insert("www.Bosse.se", 1);
  16. ns.insert("www.Ek.se", 2);
  17. assert(ns.lookup("www.Bosse.se") == 1);
  18. assert(ns.lookup("www.Ek.se") == 2);
  19. assert(ns.lookup("www.Nisse.se") == NON_EXISTING_ADDRESS);
  20. assert(! ns.remove("www.Nisse.se"));
  21. assert(ns.remove("www.Bosse.se"));
  22. assert(ns.lookup("www.Bosse.se") == NON_EXISTING_ADDRESS);
  23. }
  24.  
  25. int main() {
  26. /*
  27.   * Test the vector name server.
  28.   */
  29. VectorNameServer vns;
  30. test(vns);
  31. cout << "Vector passed ..." << endl;
  32.  
  33. /*
  34.   * Test the map name server.
  35.   */
  36. // MapNameServer mns;
  37. // test(mns);
  38. // cout << "Map passed ..." << endl;
  39.  
  40. // /*
  41. // * Test the hash name server.
  42. // * The parameter to the constructor is the size of the
  43. // * hash table.
  44. // */
  45. // HashNameServer hns(4711);
  46. // test(hns);
  47. // cout << "Hash passed ..." << endl;
  48.  
  49. return 0;
  50. }
  51.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:33: error: nameserverinterface.h: No such file or directory
prog.cpp:5:30: error: vectornameserver.h: No such file or directory
prog.cpp:12: error: ‘cpp_lab4’ is not a namespace-name
prog.cpp:12: error: expected namespace-name before ‘;’ token
prog.cpp:14: error: variable or field ‘test’ declared void
prog.cpp:14: error: ‘NameServerInterface’ was not declared in this scope
prog.cpp:14: error: ‘ns’ was not declared in this scope
prog.cpp: In function ‘int main()’:
prog.cpp:29: error: ‘VectorNameServer’ was not declared in this scope
prog.cpp:29: error: expected `;' before ‘vns’
prog.cpp:30: error: ‘vns’ was not declared in this scope
prog.cpp:30: error: ‘test’ was not declared in this scope
stdout
Standard output is empty