This repository has been archived by the owner on Oct 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServerGroupDriver.cpp
100 lines (80 loc) · 4.49 KB
/
ServerGroupDriver.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Lab 4a, Introduction To Dynamic Arrays
// Programmer: Minos Park
// Editor(s) used: Sublime Text 2
// Compiler(s) used: G++
#include "ServerGroup.h"
#include "ServerGroup.h" // the header test
#include <iostream>
using namespace std;
#include <cassert>
int main()
{
cout << "Lab 4a, Introduction To Dynamic Arrays";
cout << "Programmer: Minos Park\n";
cout << "Editor(s) used: Sublime Text 2\n";
cout << "Compiler(s) used: G++\n";
cout << "File: " << __FILE__ << endl;
cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
ServerGroup test;
test = ServerGroup(4);
if(test.serverFree()) test.useServer(10);
else cout << "Sorry come back later" << endl;
cout << "serverFree and spServerFree expected to return true" << endl;
cout << "Actual value for serverFree " << test.serverFree() << ", for spServerFree " << test.spServerFree() << endl << endl;
assert(true == test.serverFree() && true == test.spServerFree());
test.decServers(); test.decServers(); test.decServers(); test.decServers();
if(test.serverFree()) test.useServer(4);
else cout << "Sorry come back later" << endl;
cout << "serverFree and spServerFree expected to return true" << endl;
cout << "Actual value for serverFree " << test.serverFree() << ", for spServerFree " << test.spServerFree() << endl << endl;
assert(true == test.serverFree() && true == test.spServerFree());
test.decServers(); test.decServers();
for (int i = 1; i <= 5; i++)
{
if(test.serverFree()) test.useServer(i);
else cout << "Sorry come back later" << endl;
if(test.serverFree())
{
cout << "serverFree and spServerFree expected to return true" << endl;
cout << "Actual value for serverFree " << test.serverFree() << ", for spServerFree " << test.spServerFree() << endl << endl;
assert(true == test.serverFree() && true == test.spServerFree());
}
else
{
cout << "serverFree expected to return false and spServerFree expected to return true" << endl;
cout << "Actual value for serverFree " << test.serverFree() << ", for spServerFree " << test.spServerFree() << endl << endl;
assert(false == test.serverFree() && true == test.spServerFree());
}
}
if(test.spServerFree()) test.usespServer(20);
else cout << "Sorry, special server not available" << endl;
cout << "serverFree and spServerFree should return false" << endl;
cout << "Actual value for serverFree " << test.serverFree() << ", for spServerFree " << test.spServerFree() << endl << endl;
assert(false == test.serverFree() && false == test.spServerFree());
test.decServers(); test.decServers(); test.decServers();
if(test.spServerFree()) test.usespServer(10);
else cout << "Sorry, special server not available" << endl;
cout << "serverFree should return true and spServerFree should return false" << endl;
cout << "Actual value for serverFree " << test.serverFree() << ", for spServerFree " << test.spServerFree() << endl << endl;
assert(true == test.serverFree() && false == test.spServerFree());
test.decServers();
test.decServers();test.decServers();test.decServers();test.decServers();test.decServers();
test.decServers();test.decServers();test.decServers();test.decServers();test.decServers();
test.decServers();test.decServers();test.decServers();test.decServers();test.decServers();
test.decServers();test.decServers();test.decServers();test.decServers();test.decServers();
cout << "serverFree and spServerFree should return true" << endl;
cout << "Actual value for serverFree " << test.serverFree() << ", for spServerFree " << test.spServerFree() << endl << endl;
assert(true == test.serverFree() && true == test.spServerFree());
//object copy test
ServerGroup copy = test;
cout << "test: Actual value for serverFree " << test.serverFree() << ", for spServerFree " << test.spServerFree() << endl;
cout << "copy: Actual value for serverFree " << copy.serverFree() << ", for spServerFree " << copy.spServerFree() << endl;
assert(true == test.serverFree() && true == test.spServerFree());
cout << "Object copy test passed!" << endl << endl;
//object assignment test
ServerGroup copy2; copy2 = test;
cout << "test: Actual value for serverFree " << test.serverFree() << ", for spServerFree " << test.spServerFree() << endl;
cout << "copy2: Actual value for serverFree " << copy2.serverFree() << ", for spServerFree " << copy2.spServerFree() << endl;
assert(true == test.serverFree() && true == test.spServerFree());
cout << "Object assignment test passed!" << endl << endl;
}