Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
code
pugs
Commits
db531ee3
Commit
db531ee3
authored
6 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add unit test for Array
parent
1e823da3
No related branches found
No related tags found
1 merge request
!7
Feature/itemvalue
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/test_Array.cpp
+87
-0
87 additions, 0 deletions
tests/test_Array.cpp
with
88 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
db531ee3
...
@@ -4,6 +4,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PASTIS_BINARY_DIR})
...
@@ -4,6 +4,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PASTIS_BINARY_DIR})
add_executable
(
unit_tests
add_executable
(
unit_tests
test_main.cpp
test_main.cpp
test_Array.cpp
test_ItemType.cpp
test_ItemType.cpp
test_PastisAssert.cpp
test_PastisAssert.cpp
test_RevisionInfo.cpp
test_RevisionInfo.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/test_Array.cpp
0 → 100644
+
87
−
0
View file @
db531ee3
#include
<catch.hpp>
#include
<PastisAssert.hpp>
#include
<Array.hpp>
#include
<Types.hpp>
// Instantiate to ensure full coverage is performed
template
class
Array
<
int
>;
TEST_CASE
(
"Array"
,
"[utils]"
)
{
Array
<
int
>
a
(
10
);
REQUIRE
(
a
.
size
()
==
10
);
for
(
size_t
i
=
0
;
i
<
a
.
size
();
++
i
)
{
a
[
i
]
=
2
*
i
;
}
REQUIRE
(((
a
[
0
]
==
0
)
and
(
a
[
1
]
==
2
)
and
(
a
[
2
]
==
4
)
and
(
a
[
3
]
==
6
)
and
(
a
[
4
]
==
8
)
and
(
a
[
5
]
==
10
)
and
(
a
[
6
]
==
12
)
and
(
a
[
7
]
==
14
)
and
(
a
[
8
]
==
16
)
and
(
a
[
9
]
==
18
)));
SECTION
(
"checking for copies"
)
{
Array
<
const
int
>
b
{
a
};
REQUIRE
(((
b
[
0
]
==
0
)
and
(
b
[
1
]
==
2
)
and
(
b
[
2
]
==
4
)
and
(
b
[
3
]
==
6
)
and
(
b
[
4
]
==
8
)
and
(
b
[
5
]
==
10
)
and
(
b
[
6
]
==
12
)
and
(
b
[
7
]
==
14
)
and
(
b
[
8
]
==
16
)
and
(
b
[
9
]
==
18
)));
Array
<
int
>
c
{
a
};
REQUIRE
(((
c
[
0
]
==
0
)
and
(
c
[
1
]
==
2
)
and
(
c
[
2
]
==
4
)
and
(
c
[
3
]
==
6
)
and
(
c
[
4
]
==
8
)
and
(
c
[
5
]
==
10
)
and
(
c
[
6
]
==
12
)
and
(
c
[
7
]
==
14
)
and
(
c
[
8
]
==
16
)
and
(
c
[
9
]
==
18
)));
Array
<
int
>
d
=
std
::
move
(
c
);
REQUIRE
(((
d
[
0
]
==
0
)
and
(
d
[
1
]
==
2
)
and
(
d
[
2
]
==
4
)
and
(
d
[
3
]
==
6
)
and
(
d
[
4
]
==
8
)
and
(
d
[
5
]
==
10
)
and
(
d
[
6
]
==
12
)
and
(
d
[
7
]
==
14
)
and
(
d
[
8
]
==
16
)
and
(
d
[
9
]
==
18
)));
}
SECTION
(
"checking for affectations"
)
{
Array
<
const
int
>
b
;
b
=
a
;
REQUIRE
(((
b
[
0
]
==
0
)
and
(
b
[
1
]
==
2
)
and
(
b
[
2
]
==
4
)
and
(
b
[
3
]
==
6
)
and
(
b
[
4
]
==
8
)
and
(
b
[
5
]
==
10
)
and
(
b
[
6
]
==
12
)
and
(
b
[
7
]
==
14
)
and
(
b
[
8
]
==
16
)
and
(
b
[
9
]
==
18
)));
Array
<
int
>
c
;
c
=
a
;
REQUIRE
(((
c
[
0
]
==
0
)
and
(
c
[
1
]
==
2
)
and
(
c
[
2
]
==
4
)
and
(
c
[
3
]
==
6
)
and
(
c
[
4
]
==
8
)
and
(
c
[
5
]
==
10
)
and
(
c
[
6
]
==
12
)
and
(
c
[
7
]
==
14
)
and
(
c
[
8
]
==
16
)
and
(
c
[
9
]
==
18
)));
Array
<
int
>
d
;
d
=
std
::
move
(
c
);
REQUIRE
(((
d
[
0
]
==
0
)
and
(
d
[
1
]
==
2
)
and
(
d
[
2
]
==
4
)
and
(
d
[
3
]
==
6
)
and
(
d
[
4
]
==
8
)
and
(
d
[
5
]
==
10
)
and
(
d
[
6
]
==
12
)
and
(
d
[
7
]
==
14
)
and
(
d
[
8
]
==
16
)
and
(
d
[
9
]
==
18
)));
}
#ifndef NDEBUG
SECTION
(
"checking for bounds violation"
)
{
REQUIRE_THROWS_AS
(
a
[
10
],
AssertError
);
}
#endif // NDEBUG
}
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