Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
predictable_parallel_patterns
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
766587c5
authored
Apr 01, 2019
by
FritzFlorian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic tests for deque.
parent
f7f3bcfc
Pipeline
#1117
passed with stages
in 3 minutes 24 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
test/base_tests.cpp
+57
-0
No files found.
test/base_tests.cpp
View file @
766587c5
...
...
@@ -6,6 +6,7 @@
#include <vector>
#include <mutex>
#include <pls/internal/base/deque.h>
using
namespace
pls
::
internal
::
base
;
using
namespace
std
;
...
...
@@ -147,3 +148,59 @@ TEST_CASE( "aligned stack stores objects correctly", "[internal/base/aligned_sta
REQUIRE
(
pointer_five
==
pointer_three
);
}
}
TEST_CASE
(
"deque stores objects correctly"
,
"[internal/base/deque.h]"
)
{
class
my_item
:
public
deque_item
{
};
deque
<
my_item
>
deque
;
my_item
one
,
two
,
three
;
SECTION
(
"add and remove items form the tail"
)
{
deque
.
push_tail
(
&
one
);
deque
.
push_tail
(
&
two
);
deque
.
push_tail
(
&
three
);
REQUIRE
(
deque
.
pop_tail
()
==
&
three
);
REQUIRE
(
deque
.
pop_tail
()
==
&
two
);
REQUIRE
(
deque
.
pop_tail
()
==
&
one
);
}
SECTION
(
"handles getting empty by popping the tail correctly"
)
{
deque
.
push_tail
(
&
one
);
REQUIRE
(
deque
.
pop_tail
()
==
&
one
);
deque
.
push_tail
(
&
two
);
REQUIRE
(
deque
.
pop_tail
()
==
&
two
);
}
SECTION
(
"remove items form the head"
)
{
deque
.
push_tail
(
&
one
);
deque
.
push_tail
(
&
two
);
deque
.
push_tail
(
&
three
);
REQUIRE
(
deque
.
pop_head
()
==
&
one
);
REQUIRE
(
deque
.
pop_head
()
==
&
two
);
REQUIRE
(
deque
.
pop_head
()
==
&
three
);
}
SECTION
(
"handles getting empty by popping the head correctly"
)
{
deque
.
push_tail
(
&
one
);
REQUIRE
(
deque
.
pop_head
()
==
&
one
);
deque
.
push_tail
(
&
two
);
REQUIRE
(
deque
.
pop_head
()
==
&
two
);
}
SECTION
(
"handles getting empty by popping the head and tail correctly"
)
{
deque
.
push_tail
(
&
one
);
REQUIRE
(
deque
.
pop_tail
()
==
&
one
);
deque
.
push_tail
(
&
two
);
REQUIRE
(
deque
.
pop_head
()
==
&
two
);
deque
.
push_tail
(
&
three
);
REQUIRE
(
deque
.
pop_tail
()
==
&
three
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment