Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Summa Actors
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Numerical_Simulations_Lab
Actors
Summa Actors
Commits
78da8fab
Commit
78da8fab
authored
2 years ago
by
KyleKlenk
Browse files
Options
Downloads
Patches
Plain Diff
modified unit tests to compliment the changes to the output structure
parent
b0605bfa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build/source/actors/OutputManager.h
+12
-0
12 additions, 0 deletions
build/source/actors/OutputManager.h
build/source/testing/testing_main.cc
+55
-44
55 additions, 44 deletions
build/source/testing/testing_main.cc
with
67 additions
and
44 deletions
build/source/actors/OutputManager.h
+
12
−
0
View file @
78da8fab
...
...
@@ -41,6 +41,13 @@ class ActorRefList {
return
list
.
size
()
==
this
->
maxSize
;
}
/**
* Adds An Actor and its return message as a tuple to this->list
* actor - the actor ref of the actor being added to this->list
* returnMessage - Either 9999 (place holder and specifies to send a done_write_v message) or
* this is the current forcingFileList index that allows the file_access actor to know the number
* of steps the HRU actor that needs to compute
*/
void
addActor
(
caf
::
actor
actor
,
int
index
,
int
returnMessage
)
{
if
(
this
->
isFull
())
{
throw
"List is full, cannot add actor to this list"
;
...
...
@@ -56,6 +63,10 @@ class ActorRefList {
list
.
push_back
(
std
::
make_tuple
(
actor
,
returnMessage
));
}
/**
* Return a tuple of an actor and its returnMessage.
* The return message is 9999 or the index of the forcingFile it needs to acces
*/
std
::
tuple
<
caf
::
actor
,
int
>
popActor
()
{
if
(
list
.
empty
())
{
throw
"List is empty, nothing to pop"
;
...
...
@@ -114,6 +125,7 @@ class OutputManager {
*
* @param actor Actor reference
* @param index Actor Index
* @param returnMessage Forcing File index or 9999
* @return int The list index that actor is added to.
*/
int
addActor
(
caf
::
actor
actor
,
int
index
,
int
returnMessage
)
{
...
...
This diff is collapsed.
Click to expand it.
build/source/testing/testing_main.cc
+
55
−
44
View file @
78da8fab
...
...
@@ -94,6 +94,8 @@ void test_calculateTime() {
void
testActorRefList
(
caf
::
actor_system
&
sys
)
{
caf
::
scoped_actor
self
{
sys
};
auto
a1
=
sys
.
spawn
(
test_coordinator
);
auto
a2
=
sys
.
spawn
(
test_coordinator
);
auto
a3
=
sys
.
spawn
(
test_coordinator
);
...
...
@@ -103,49 +105,57 @@ void testActorRefList(caf::actor_system& sys) {
auto
om
=
new
ActorRefList
(
5
);
// Test Adding Actor To ActorRefList
IS_TRUE
(
om
->
getCurrentSize
()
==
0
);
om
->
addActor
(
a1
);
om
->
addActor
(
a1
,
1
,
9999
);
IS_TRUE
(
om
->
getCurrentSize
()
==
1
);
om
->
addActor
(
a2
);
om
->
addActor
(
a2
,
2
,
3
);
IS_TRUE
(
om
->
getCurrentSize
()
==
2
);
om
->
addActor
(
a3
);
om
->
addActor
(
a3
,
3
,
7
);
IS_TRUE
(
om
->
getCurrentSize
()
==
3
);
om
->
addActor
(
a4
);
om
->
addActor
(
a4
,
4
,
9999
);
IS_TRUE
(
om
->
getCurrentSize
()
==
4
);
om
->
addActor
(
a5
);
om
->
addActor
(
a5
,
5
,
8
);
IS_TRUE
(
om
->
getCurrentSize
()
==
5
);
// Try adding an actor to a full list
try
{
om
->
addActor
(
a6
);
om
->
addActor
(
a6
,
6
,
9999
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
IS_TRUE
(
om
->
getCurrentSize
()
==
5
)
}
// Test isFull
IS_TRUE
(
om
->
isFull
());
// Test removing actors from the list
auto
a7
=
om
->
popActor
();
IS_TRUE
(
a7
==
a5
);
IS_TRUE
(
get
<
0
>
(
a7
)
==
a5
&&
get
<
1
>
(
a7
)
==
8
);
IS_TRUE
(
om
->
getCurrentSize
()
==
4
);
auto
a8
=
om
->
popActor
();
IS_TRUE
(
a8
==
a4
);
IS_TRUE
(
get
<
0
>
(
a8
)
==
a4
&&
get
<
1
>
(
a8
)
==
9999
);
IS_TRUE
(
om
->
getCurrentSize
()
==
3
);
auto
a9
=
om
->
popActor
();
IS_TRUE
(
a9
==
a3
);
IS_TRUE
(
get
<
0
>
(
a9
)
==
a3
&&
get
<
1
>
(
a9
)
==
7
);
IS_TRUE
(
om
->
getCurrentSize
()
==
2
);
auto
a10
=
om
->
popActor
();
IS_TRUE
(
a10
==
a2
);
IS_TRUE
(
get
<
0
>
(
a10
)
==
a2
&&
get
<
1
>
(
a10
)
==
3
);
IS_TRUE
(
om
->
getCurrentSize
()
==
1
);
auto
a11
=
om
->
popActor
();
IS_TRUE
(
a11
==
a1
);
IS_TRUE
(
get
<
0
>
(
a11
)
==
a1
&&
get
<
1
>
(
a11
)
==
9999
);
try
{
om
->
popActor
();
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
IS_TRUE
(
om
->
getCurrentSize
()
==
0
)
}
IS_TRUE
(
om
->
isEmpty
())
}
void
testOutputManager
(
caf
::
actor_system
&
sys
)
{
caf
::
scoped_actor
self
{
sys
};
auto
a1
=
sys
.
spawn
(
test_coordinator
);
auto
a2
=
sys
.
spawn
(
test_coordinator
);
auto
a3
=
sys
.
spawn
(
test_coordinator
);
...
...
@@ -157,7 +167,6 @@ void testOutputManager(caf::actor_system& sys) {
auto
a9
=
sys
.
spawn
(
test_coordinator
);
auto
a10
=
sys
.
spawn
(
test_coordinator
);
std
::
cout
<<
"Creating Output Manager"
<<
std
::
endl
;
auto
OM
=
new
OutputManager
(
5
,
10
);
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
...
...
@@ -169,55 +178,56 @@ void testOutputManager(caf::actor_system& sys) {
std
::
cerr
<<
msg
<<
std
::
endl
;
}
OM
->
addActor
(
a1
,
1
);
// Test adding actors and ensuring they go to the correct List
OM
->
addActor
(
a1
,
1
,
1
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a2
,
2
);
OM
->
addActor
(
a2
,
2
,
2
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a3
,
3
);
OM
->
addActor
(
a3
,
3
,
3
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a4
,
4
);
OM
->
addActor
(
a4
,
4
,
4
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a5
,
5
);
OM
->
addActor
(
a5
,
5
,
5
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a6
,
6
);
OM
->
addActor
(
a6
,
6
,
6
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a7
,
7
);
OM
->
addActor
(
a7
,
7
,
7
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a8
,
8
);
OM
->
addActor
(
a8
,
8
,
8
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
3
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
4
)
==
0
);
OM
->
addActor
(
a9
,
9
);
OM
->
addActor
(
a9
,
9
,
9
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
...
...
@@ -225,7 +235,7 @@ void testOutputManager(caf::actor_system& sys) {
IS_TRUE
(
OM
->
getSize
(
4
)
==
1
);
IS_TRUE
(
!
OM
->
isFull
(
4
))
OM
->
addActor
(
a10
,
10
);
OM
->
addActor
(
a10
,
10
,
10
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
...
...
@@ -237,14 +247,15 @@ void testOutputManager(caf::actor_system& sys) {
IS_TRUE
(
OM
->
isFull
(
3
))
IS_TRUE
(
OM
->
isFull
(
4
))
// Test Poping Actors
auto
a11
=
OM
->
popActor
(
0
);
IS_TRUE
(
a11
==
a2
);
IS_TRUE
(
get
<
0
>
(
a11
)
==
a2
&&
get
<
1
>
(
a11
)
==
2
);
auto
a14
=
OM
->
popActor
(
0
);
IS_TRUE
(
a14
==
a1
);
IS_TRUE
(
get
<
0
>
(
a14
)
==
a1
&&
get
<
1
>
(
a14
)
==
1
);
auto
a12
=
OM
->
popActor
(
1
);
IS_TRUE
(
a12
==
a4
);
IS_TRUE
(
get
<
0
>
(
a12
)
==
a4
&&
get
<
1
>
(
a12
)
==
4
);
auto
a13
=
OM
->
popActor
(
4
);
IS_TRUE
(
a13
==
a10
);
IS_TRUE
(
get
<
0
>
(
a13
)
==
a10
&&
get
<
1
>
(
a13
)
==
10
);
IS_TRUE
(
OM
->
getSize
(
0
)
==
0
);
IS_TRUE
(
OM
->
getSize
(
1
)
==
1
);
IS_TRUE
(
OM
->
getSize
(
2
)
==
2
);
...
...
@@ -266,11 +277,11 @@ void testOutputManager(caf::actor_system& sys) {
delete
OM
;
std
::
cout
<<
"Creating Output Manager 2 with 3 vectors"
<<
std
::
endl
;
//
std::cout << "Creating Output Manager 2 with 3 vectors" << std::endl;
auto
OM2
=
new
OutputManager
(
3
,
10
);
try
{
OM2
->
addActor
(
a1
,
1
);
OM2
->
addActor
(
a1
,
1
,
1
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
...
...
@@ -278,7 +289,7 @@ void testOutputManager(caf::actor_system& sys) {
IS_TRUE
(
OM2
->
getSize
(
1
)
==
0
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
0
);
try
{
OM2
->
addActor
(
a2
,
2
);
OM2
->
addActor
(
a2
,
2
,
2
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
...
...
@@ -286,7 +297,7 @@ void testOutputManager(caf::actor_system& sys) {
IS_TRUE
(
OM2
->
getSize
(
1
)
==
0
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
0
);
try
{
OM2
->
addActor
(
a3
,
3
);
OM2
->
addActor
(
a3
,
3
,
3
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
...
...
@@ -294,7 +305,7 @@ void testOutputManager(caf::actor_system& sys) {
IS_TRUE
(
OM2
->
getSize
(
1
)
==
0
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
0
);
try
{
OM2
->
addActor
(
a4
,
4
);
OM2
->
addActor
(
a4
,
4
,
4
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
...
...
@@ -302,31 +313,31 @@ void testOutputManager(caf::actor_system& sys) {
IS_TRUE
(
OM2
->
getSize
(
1
)
==
1
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
0
);
try
{
OM2
->
addActor
(
a
5
,
5
);
OM2
->
addActor
(
a
7
,
7
,
7
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
IS_TRUE
(
OM2
->
getSize
(
0
)
==
3
);
IS_TRUE
(
OM2
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM2
->
getSize
(
1
)
==
1
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
1
);
try
{
OM2
->
addActor
(
a
6
,
6
);
OM2
->
addActor
(
a
8
,
8
,
8
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
IS_TRUE
(
OM2
->
getSize
(
0
)
==
3
);
IS_TRUE
(
OM2
->
getSize
(
1
)
==
3
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
0
);
IS_TRUE
(
OM2
->
getSize
(
1
)
==
1
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
2
);
try
{
OM2
->
addActor
(
a
7
,
7
);
OM2
->
addActor
(
a
5
,
5
,
5
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
IS_TRUE
(
OM2
->
getSize
(
0
)
==
3
);
IS_TRUE
(
OM2
->
getSize
(
1
)
==
3
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
1
);
IS_TRUE
(
OM2
->
getSize
(
1
)
==
2
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
2
);
try
{
OM2
->
addActor
(
a
8
,
8
);
OM2
->
addActor
(
a
6
,
6
,
6
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
...
...
@@ -334,7 +345,7 @@ void testOutputManager(caf::actor_system& sys) {
IS_TRUE
(
OM2
->
getSize
(
1
)
==
3
);
IS_TRUE
(
OM2
->
getSize
(
2
)
==
2
);
try
{
OM2
->
addActor
(
a9
,
9
);
OM2
->
addActor
(
a9
,
9
,
9
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
std
::
endl
;
}
...
...
@@ -345,7 +356,7 @@ void testOutputManager(caf::actor_system& sys) {
IS_TRUE
(
OM2
->
isFull
(
1
));
IS_TRUE
(
!
OM2
->
isFull
(
2
));
try
{
OM2
->
addActor
(
a10
,
10
);
OM2
->
addActor
(
a10
,
10
,
10
);
}
catch
(
const
char
*
msg
)
{
std
::
cerr
<<
msg
<<
10
<<
std
::
endl
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment