-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtestsequence.cpp
121 lines (103 loc) · 2.44 KB
/
testsequence.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "testsequence.h"
#include<iostream>
using namespace std;
TestSequence::TestSequence()
{
//ctor
this->message = vector<Message>();
this->priority = 0;
}
TestSequence::TestSequence(const TestSequence& another)
{
//copy ctor
this->message = another.getTestSequence();
this->priority = another.getPriority();
this->conditions = another.getConditions();
this->number = another.getNum();
}
void TestSequence::display()
{
Message msg;
cout<<"Test Sequence : ";
for(unsigned int i =0; i<(this->message).size(); i++)
{
msg = (this->message)[i];
cout<<msg.getID()<<" ";
}
cout<<" | Priority: "<<(this->priority)<<endl;
}
int TestSequence::getLength()
{
return (this->message).size();
}
int TestSequence::compareTo(TestSequence ts)
{
int k = ts.getPriority() - (this->getPriority());
if(k==0)
return ((this->getLength() < ts.getLength()) ? (this->getLength()) : ts.getLength());
else
return k;
}
int TestSequence::getPriority() const
{
return (this->priority);
}
void TestSequence::setPriority(int priority)
{
this->priority = priority;
}
void TestSequence::incrementPriority(int k)
{
this->priority += k;
}
void TestSequence::decrementPriority(int k)
{
this->priority -= k;
}
void TestSequence::addMessage(Message message)
{
(this->message).push_back(message);
}
Message TestSequence::getLastMessage()
{
return (this->message)[(this->message).size() -1];
}
vector<Message> TestSequence::getTestSequence() const
{
return this->message;
}
void TestSequence::appendSequence(TestSequence ts)
{
vector<Message> temp = ts.getTestSequence();
(this->message).insert((this->message).end(), temp.begin(), temp.end());
}
bool TestSequence::operator < (const TestSequence& temp) const
{
return((this->getPriority()) > temp.getPriority());
}
map<string,int> TestSequence::getConditions() const
{
return this->conditions;
}
void TestSequence::evalConditions()
{
for(unsigned int i=0; i<(this->message).size(); i++)
{
string m_id = (this->message)[i].getID();
if(!Message_List[m_id])
continue;
string c_id = Message_List[m_id]->getID();
int part = Partitions[m_id];
ostringstream temp;
temp<<part;
(this->conditions)[c_id+temp.str()] = 1;
}
}
int TestSequence::getNum() const
{
return this->number;
}
void TestSequence::setNum(int num)
{
this->number = num;
}