-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_server.cpp
More file actions
54 lines (45 loc) · 1.68 KB
/
test_server.cpp
File metadata and controls
54 lines (45 loc) · 1.68 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "test_server.h"
#include "server.h"
#include <iostream>
#include <sstream>
bool test_server() {
std::string expected = "";
bool passed = true; // Optimist!
//
// Test constructor
//
std::string x_name = "Charlie Chaplin";
std::string x_id = "tramp";
std::string x_phone = "555-1212";
double x_salary = 15;
Mice::Server server{x_name, x_id, x_phone, x_salary};
// std::ostringstream os;
// os << server;
// if (os.str() != " Server: Fudge Ripple $1.50") {
// std::cerr << "#### Server operator<< fail" << std::endl;
// std::cerr << "Expected: Server: Fudge Ripple $1.50" << std::endl;
// std::cerr << "Actual: " << os.str() << std::endl;
// }
if (server.name() != x_name ||
server.id() != x_id ||
server.phone() != x_phone ||
server.salary() != x_salary ||
server.num_orders() != 0 ||
!server.is_active()) {
std::cerr << "#### Server constructor fail" << std::endl;
std::cerr << "Expected: " << x_name << ','
<< x_id << ','
<< x_phone << ','
<< x_salary << ','
<< '0' << ','
<< "is active" << std::endl;
std::cerr << "Actual: " << server.name() << ','
<< server.id() << ','
<< server.phone() << ','
<< server.salary() << ','
<< server.num_orders() << ','
<< (server.is_active() ? "is active" : "is not active") << std::endl;
passed = false;
}
return passed;
}